Why isn't there a Guid.IsNullOrEmpty() method

前端 未结 7 1343
不思量自难忘°
不思量自难忘° 2020-12-24 00:19

This keeps me wondering why Guid in .NET does not have IsNullOrEmpty() method (where empty means all zeros)

I need this at several places in my ASP.NET

7条回答
  •  不思量自难忘°
    2020-12-24 00:45

    For one thing, Guid is not nullable. You could check:

    myGuid == default(Guid)
    

    which is equivalent to:

    myGuid == Guid.Empty
    

提交回复
热议问题