c# - Incorrect value when assigning to nullable DateTimes using Immediate Window -


i have following code:

using system;  namespace consoleapplication1 {     class program     {         static void main()         {             var foo = new foo             {                 thedate = datetime.now             };              console.read();             }     }      class foo     {         public datetime? thedate { get; set; }     } } 

i set breakpoint on line console.read(); , using immediate window in visual studio 2015, observe value of foo.thedate:

observing initial value

now set value of foo.thedate using immediate window christmas day 1990 (any date suffice, using easy remember example):

assigning new value

i see value echo'd me, looks fine. however, when observe value, returned date different:

observing newly set value

what's happening here?

edit: further issue, if use regular datetime (not nullable), , try same example code, on attempting assignment using foo.thedate = new datetime(2012, 12, 25), immediate window errors system.reflection.targetparametercountexception , message "parameter count mismatch".


Comments

Popular posts from this blog

html - Difficulties with background-image property -

visual studio code - What does the isShellCommand property actually do and how should you use it? -

ios - Segue not passing data between ViewControllers -