Monday, 12 August 2013

? Constructor handling with nullable types

? Constructor handling with nullable types

small question, just for understanding: I have 2 nullable datetimes. I
read out the create time and the update time, both can be filled. So I
want to check which is later:
lastChangedIndrole = (tmpCreate > tmpUpdate ? tmpCreate : tmpUpdate);
But here happen some strange things. I would expect to throw a error when
f.e. tmpUpdate is null, but it seem to return something, but not the
corret value but just the second, in my example the update.
Is there anything I dont understand? I'd think the code checks the
miliseconds to 1900 and if there is a null value an error gets thrown. But
this doesnt happen. Is that some magic I dont understand?
P.S. : Is there a special word for the ? constructor like IIF in vb? It's
hard to search something.
Thanks and a good start in the week
Matthias

No comments:

Post a Comment