Check if Nullable Guid is empty in c#

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}


SomeProperty.HasValue I think it's what you're looking for.

See DevDave's or Sir l33tname's answer instead.

EDIT : btw, you can write System.Guid? instead of Nullable<System.Guid> ;)


Note that HasValue will return true for an empty Guid.

bool validGuid = SomeProperty.HasValue && SomeProperty != Guid.Empty;