Can't set Date on SmartDate

Can't set Date on SmartDate

Old forum URL: forums.lhotka.net/forums/t/2468.aspx


boo posted on Friday, March 02, 2007

I get the following compile time error when setting the Date value on a property that is a SmartDate but the Date property is get/set - what's going on?

Cannot modify the return value of 'ChildObject.EffectiveDate' because it is not a variable

The offending code causing the error is:

obj.ChildObject.EffectiveDate.Date = DateTime.Now;

ajj3085 replied on Friday, March 02, 2007

That's normal because EffectiveDate is a struct, and you can't modify the properties of a struct..

change your code to:
obj.ChildObject.EffectiveDate = new SmartDate( DateTime.Now )

Assuming EffectiveDate is a SmartDate..

boo replied on Friday, March 02, 2007

duh...that's right.  Thanks for helping me see the obvious...get so use to working with classes you forget struts have those special rules!

Copyright (c) Marimer LLC