Guid == null should not be allowed by the compiler
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Possible Duplicate: C# okay with comparing value types to null The behaviour described below is specific to .net-3.5 only Hello, I just ran across the most astonishing behavior in the C# compiler; I have the following code: Guid g1 = Guid.Empty; bool b1= (g1 == null); Well, Guid is not nullable therefore it can never be equal to null . The comparison i'm making in line 2 always returns false . If you make the same thing for an integer, the compiler issues an warning saying the result will always be false: int x=0; bool b2= (x==null); My