c# - How to convert nullable DateTime? -


string fc = ....... dictionary<string, string> fcdata = serializer.deserialize<dictionary<string, string>>(fc);   if (!string.isnullorwhitespace(fcdata["diploma.graduationbegindate"]))   datetime? graduationbegindate = convert.todatetime(fcdata["diploma.graduationbegindate"]); 

error : {"object reference not set instance of object."}

this code . fcdata has value, count =11 , fcdata["diploma.graduationbegindate"] value 10.05.2016 why doesn't work ? me ?

you can affect datetime datetime? :

datetime t1 = somedate; datetime? t2; t2 = t1; <- works 

in contrary :

datetime? t1 = somedate; datetime t2; t2 = t1; <- won't work, need cast t2 = (datetime)t1; 

hope help.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -