Guid == null should not be allowed by the compiler

前端 未结 4 1990
日久生厌
日久生厌 2020-12-05 17:02

The behaviour described below is specific to .net-3.5 only

I just ran across the most astonishing behavior in the C# compiler;

I

4条回答
  •  春和景丽
    2020-12-05 17:42

    The comparison is valid because the compiler converts the Guid to a Nullable and then it makes sense.

    There is a bug report on the warning not being issued here.

    See here here for a fuller explanation from Eric Lippert.

提交回复
热议问题