Why type “int” is never equal to 'null'?

前端 未结 8 1377
迷失自我
迷失自我 2020-12-05 22:50
int n == 0;

if (n == null)    
{  
    Console.WriteLine(\"......\");  
}

Is it true that the result of expression (n == null) is alw

8条回答
  •  粉色の甜心
    2020-12-05 23:28

    "Value types" in .NET (like int, double, and bool) cannot, by definition, be null - they always have an actual value assigned. Check out this good intro to value types vs. reference types.

提交回复
热议问题