Use nullable objects in expressions : Nullable : Data Type C# Examples


C# Examples » Data Type » Nullable »

 

Use nullable objects in expressions









    
using  System;  
  
class  MainClass  {  
    public  static  void  Main()  {  
        int?  count  =  null;  
        int?  result  =  null;  
  
        int  incr  =  10;  
  
        result  =  count  +  incr;  
  
        if(result.HasValue)  
            Console.WriteLine("result  has  this  value:  "  +  result.Value);  
        else    
            Console.WriteLine("result  has  no  value");          
  
    }  
}
    
   
  
   



Output

result has no value


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Nullable