Tuesday, May 27, 2014

How to checking the NLL value for the integer in ASP.Net c#

Step 1:- First write code in the button click like this

int value = null;

it will show error because normally not possible to assign null value to the int

Step 2:- By using “?” we can able to assign the null values to the integer like

int? value = null;

for checking this process using the brake point the code and checking one by one code line

if (value.HasValue == true)
{
    Console.WriteLine("True");
}

 Step 3:-
When  value.HasValue calls it will default false
Then we assign value to the integer
int? value = 1;

then automatically value.HasValue returns “True”

Full Code:-
int? value = null;

Console.WriteLine(value.HasValue);

Output: FALSE

Value=1;
Console.WriteLine(value.HasValue);

Output: TRUE



For any clarifications or queries please don’t hesitate to call or Email 

Phone :- + 91-9492179390


Email :- lannam@technobrainltd.com (or) lokeshtec@gmail.com 

No comments:

Post a Comment