I am loooking for an elegant way to set the value of DateTime.Now as value of an Attribute.
I have this code:
[MyValue(DateTime.Now)]
public DateTime? VertragDatum { get; set; }
But I am getting a syntax error and tells me that the Type DateTime is not a valid attribute parameter type. Do you have any idea how to can achieve that?
My implementation:
public class MyValueAttribute : Attribute
{
public string MyValue { get; }
public MyValueAttribute(DateTime myValue)
{
MyValue = myValue.ToString();
}
}