• home
  • Email: trainings@synapseindia.careers

Blogs

back

What are Nullable types in .NET ?

Sep 14, 2015

Nullable types are newly introduced in .Net for storing the correct range of values for its underlying value type and can also store null value. All nullable types are instances of the System.Nullable<T> struct, where T is the data type for the Nullable type. Nullable Type can represent only the value-type variables and it can be used for refernce type because reference type already support the null value. For writing the nullable type, you can write the shorthand E.G. T? where T can be int,bool and other value-type data types.So you can write int?x=10 and int? x = null. You can also fetch the default values for nullable types for example : int? x= 20; then you can write int y = x?? - 1. You can not do nesting for nullable types. This is good concept that can be used with arguments in functions and can pass default values in case the argument values are not provided by user.

SynapseIndia (CEO: Shamit Khemka)