C#/.NET Little Wondres: The Nullable<T> struct

added by BlackRabbitCoder
7/12/2012 8:45:38 PM

0 Kicks, 78 Views

The Nullable<T> is a handy structure that was created to give us a consistent way to handle “optional” instances of value types. Nullable<T> instances can be assigned to null or compared with null, which really is syntactical sugar which creates a default instance or checks the HasValue property respectively. In addition, you can use the GetValueOrDefault() method or the null-coalescing operator (??) to query the value, or provide a substitute if the value was never set.


1 comments

BlackRabbitCoder
7/12/2012 8:46:16 PM
new post