Thumb

Nullable Types

1/7/2020 5:44:53 AM

Nullable Types

Esteem sorts can't be doled out as invalid, reference sorts can. Applications that work with databases manage the invalid esteem. Along these lines, uncommon nullable sorts were brought into the C# dialect. Nullable sorts are occurrences of the System.Nullable<T> struct.

Ex:

using System;  
	  
class Employee  
{  
static void Main()  
 {  
  Nullable<bool> Name= null;  
  int? Age = null;  
 Console.WriteLine(Name.HasValue);  
 Console.WriteLine(Age.HasValue);  
 }  
}  

A straightforward illustration showing nullable sorts.
Nullable<bool> male = invalid;  
int? age = invalid;  
There are two courses to proclaim a nullable sort. Either with the Nullable<T> bland structure in which the sort is determined between the edge sections, or we can utilize a question mark after the sort.