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
:
now set value of foo.thedate
using immediate window christmas day 1990 (any date suffice, using easy remember example):
i see value echo'd me, looks fine. however, when observe value, returned date different:
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
Post a Comment