Check if Nullable Guid is empty in c#

c#, guid, nullable

Solution

If you want be sure you need to check both

SomeProperty == null || SomeProperty == Guid.Empty

Because it can be null 'Nullable' and it can be an empty GUID something like this {00000000-0000-0000-0000-000000000000}

Problem

Quoting from an answer from this question. Guid is a value type, so a variable of type Guid can't be null to start with. What then if I see this? ``` public Nullable<System.Guid> SomeProperty { get; set; } ``` how should I check if this is null? Like this? ``` (SomeProperty == null) ``` or like this? ``` (SomeProperty == Guid.Empty) ```

Original source

Related problems