Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How does C# judge that integer variables are not empty?
How does C# judge that integer variables are not empty?
With int? To define integers.

Use? System;

Namespace? ConsoleApplication 15

{

Class? procedure

{

Static electricity Invalid? Main(string[]? Parameter)

{

int? x? =? null

//? Judge whether it is empty.

What if? (! x.HasValue)

{

Console. WriteLine("x is empty ");

}

x? =? 100;

//? Judge whether it is valuable.

What if? (x.HasValue)

{

Console. WriteLine(x);

}

}

}

}