While moderating posts over on the Asp.Net forums, I ran into a thread containing questions about using Nullable types.
Nullable types are a simple concept: Allow value types to have the value of null. Typically, an integer or float cannot be null: When in scope, they always exist and therefore must have a numeric value (zero is not null, it is a numeric value).
Here is the subtlety (or in technical terms, a really ooky statement):
Nullable types with the value of null are not really null.
Look at this code:
int Test1 = 0;
int? Test2 = null;
Object Test3 = null;
Response.Write("Test1: " + Test1.ToString() + "<br />");
Response.Write("Test2: " + Test2.ToString() + "<br />");
It is odd that we can access Test2 when its value is null but we get no output string.
Microsoft's web site correctly describes nullable types (http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx):
"A nullable type can represent the correct range of values for its underlying value type, plus an additional null value."
But most of us gloss over descriptions like that and until you see it demonstrated, you may not truly understand.
I hope someone finds this useful, Steve Wellens.