This is MY blog. The views represented here are not in relation to anybody else. Please read my full disclaimer for a more complete disclaimer.
I was recently doing some development that needed to allow for an int to be null. However in .NET that isn't allowed by default.
So I started doing some searches and found that there is a way to have nullable types in C#.
There are two ways to do this:
1. Nullable<int> x = new Nullable<int>(125);
2. int? x = 125
Now what I find interesting is how you can find out if this is null. You can do, again, one of two things.
1. if(x.HasValue).....
2. if(x != null)....
I actually prefer option two in both situations because that just looks normal to me.
HT: Eric Gunnerson
Related posts