Making an integer null

Although you often see an error message when trying to return null for an integer, it is possible to return a null value if you declare the integer specifically

int? value = new int?();

if(value == null)
{
// something
}

note the ? mark after the int declaration. That is the key to allowing nulls for integers

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply