Explanation for Nullable Types in detail - C#
I am interested in learning programming languages. I have already leart Java, C, C++ and HTML. Now recently I have started to Csharp. Although quite interesting, I am finding some of its feature difficult to understand. There is this one feature of Csharp known as Nullable Types. I have been not able to percieve what excatly is Nullable Types in Csharp.
Re: Explanation for Nullable Types in detail - C#
C# 2.0 has introduced many new key features which are really very helpful. Nullable types is one of this key features. We can define a Nullable type as a particular data type which consists o the defined data type value or the null value. If a value type variable can be assigned the value of Null, it is said to represent a Nullable Type in C#. Nullable types are used to overcome the short comings of value types as they cannot hold a Null value.
Re: Explanation for Nullable Types in detail - C#
From the name itself it is very clear that Nullable types have the ability to store value of Null. Therefore, a nullable type can represent the normal range of values for its underlying value type, plus an additional null value. They are similar to generic data types with the only difference being a wrapper structure written aroung the generic data type which permits it to store value of Null. Nullable types in Csharp are instances of the System.Nullable struct.
Re: Explanation for Nullable Types in detail - C#
Csharp has succesfully brought out many interesting concepts through C# 2.0. One exiting concept is the that of the Nullable Types in Csharp. Nullable types makes it possible for you, where you are able to have a primitive type with a null or unknown value. A nullable type can be declared similar to normal variable but with ? modifier at the end of keyword.
eg.
int? Val = null;
or
Nullable<int> Val = null;
where we can use int? instead of Nullable<int>