Passing Null value to integer

Last Reply on Mar 16, 2012 11:47 PM By Mudassar

Posted on Mar 16, 2012 11:45 PM

Hi . Actually Iam performng a sql operation after which i get a return value as integer....

but since when data doesmot exists then , it returns null or nothing .... but when i pass this value to integer var..... iam getting a error 

i.e object reference not set to an instance of an object

can u please help me hw can i pass a null value to integer and check whether anything exists or not....

Posted on Mar 16, 2012 11:47 PM

You can use Nullable integer

  int? i = 0;

        if (i.HasValue)
            int b = i.Value;