I would like to put a constant date time in an attribute parameter, how do i make a constant datetime? It's related to a ValidationAttribute of the EntLib Validation Application Block but applies to other attributes as well.
When I do this:
private DateTime _lowerbound = new DateTime(2011, 1, 1);
[DateTimeRangeValidator(_lowerbound)]
I'll get:
An object reference is required for the non-static field, method, or property _lowerbound
And by doing this
private const DateTime _lowerbound = new DateTime(2011, 1, 1);
[DateTimeRangeValidator(_lowerbound)]
I'll Get:
The type 'System.DateTime' cannot be declared const
Any ideas? Going this way is not preferable:
[DateTimeRangeValidator("01-01-2011")]