Nullables? Detecting them
Posted
by Aren B
on Stack Overflow
See other posts from Stack Overflow
or by Aren B
Published on 2010-05-08T19:54:38Z
Indexed on
2010/05/08
19:58 UTC
Read the original article
Hit count: 328
Ok, im still a bit new to using nullable types.
I'm writing a reflecting object walker for a project of mine, im getting to the point where im setting the value of a reflected property with the value i've retrieved from a reflected property.
The value i've retrieved is still in object
form, and it dawned on me, since i want my object walker to return null when it can't find something, (I thought about throwing an exception, but i want this to soft-fail when something's wrong).
Anyway, some of the values im setting/getting are decimal
bool
etc... so it dawned on me that i should just NOT set a non-nullable value, but I realized I straight up don't know how to tell decimal
from decimal?
Is it enough to key on if the Type of the property im setting is inherited from ValueType
?
© Stack Overflow or respective owner