Null Coalescing Operator : Nullable : Data Type C# Examples


C# Examples » Data Type » Nullable »

 

Null Coalescing Operator









    
using  System;

class  MainClass
{
      static  void  Main()
      {
            int?  nullableInteger  =  null;
            Console.WriteLine("nullableInteger:  {0}",  nullableInteger  ??  -1);

            nullableInteger  =  10;
            Console.WriteLine("nullableInteger:  {0}",  nullableInteger  ??  -1);
      }
}
    
   
  
   



Output

nullableInteger: -1
nullableInteger: 10


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Nullable