Introduction to .NET Framework 3.0/Nullable Types

From Wikibooks, open books for an open world
Jump to navigation Jump to search

.NET 3.0 supports nullable data types. Previously, nullification of only 'int' values were supported by .NET. However, this addition comes as a big boon to developers who might find it easy even to have 'null date-time' values and the kind. Values might be nullifed in .NET by placing a '?' after the datatype name in the variable declaration

Examples

int? num = null;
DateTime? dt = null;

Note: Nullable support is available since .Net 2.0