Problem with SmartDate as a Property!

Problem with SmartDate as a Property!

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


david.wendelken posted on Tuesday, April 24, 2007

Here's a sample test class that we'll use to illustrate this problem:

public class TestClass
{
    
private SmartDate _mySmartDate = new SmartDate();

     public SmartDate MySmartDate
    {
          get { return _mySmartDate; }
          set { _mySmartDate = value; }
     }

}

Here's a test script that illustrates the problem:


// This works great!
SmartDate d = new SmartDate();
d.Date =
DateTime.Now;

// This does't work at all.
TestClass
tc = new TestClass();
tc.MySmartDate.Date = DateTime.Now;

// compile error for above line is this:
//Cannot modify the return value of 'TestClass.MySmartDate' because it is not a variable 

// This does work.
TestClass tc = new TestClass();
tc.MySmartDate = n
ew SmartDate(DateTime.Now);

It appears that the set logic in the property definition trumps your ability to modify properties of the property object.

Is this intended?  Is there a work-around? 

david.wendelken replied on Tuesday, April 24, 2007

oops.  put in the wrong forum. :(

Copyright (c) Marimer LLC