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

前端 未结 7 1278
不思量自难忘°
不思量自难忘° 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:47

    You know I see this statements like this one all the time

    Guid is a value type, so a variable of type Guid can't be null to start with

    but it is just NOT TRUE.

    Agreed you can not programmatic set a Guid to null, but when some SQL pulls in a UniqueIdentifier and maps it to a Guid, and if that value is null in the db, the value comes up as null in the C#.

    0 讨论(0)
提交回复
热议问题