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

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -