c# - How to return DateTime.Today as a FieldNullValue in FileHelpers -


i'm trying set fieldnullvalue datetime variable in filehelpers class today value (so if when read .csv there no entry, defaults today's date). code i've tried is:

[fieldoptional] [fieldnullvalue(datetime.today)] public datetime date; 

however error

"error 1 attribute argument must constant expression, typeof expression or array creation expression of attribute parameter type".

please can explain i'm doing wrong?

the obvious approach

[fieldoptional] [fieldnullvalue(typeof(datetime), datetime.today.tostring("m-dd-yyyy"))]  public datetime date;  

but seems fieldnullvalueattribute unable evaluate expressions case datetime.today.tostring() , way go hardcode fixed date string (not want in our code):

[fieldoptional] [fieldnullvalue(typeof(datetime), "5/15/2015")]  public datetime date; 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -