Thursday, August 9, 2007

Nullable Types

NULLABLE TYPES
• Nullable types are instances of the System.Nullable struct
• A nullable type can represent the normal range of values for its underlying value type, plus an additional null value
• For example a Nullable can be assigned any value from -2147483647 to 2147483647, or it can be assigned a null value
• Same with type bool, which can take true, false and null
• Nullable is used while dealing with databases where element may not be assigned a value
• Syntax is: int? x = null or double? d = 4.108;
• To identify a nullable type: int? x = null; Type t = i.GetType(); Console.WriteLine(t.FullName);

No comments: