Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Guid with all zero elements?

Tags:

c#

guid

zero

How to create a Guid that all of its elements are zero. i.e. {00000000-0000-0000-0000-000000000000}. I could use:

Guid.Parse("{00000000-0000-0000-0000-000000000000}")

But is there any easier method for that ?

like image 234
Ehsan88 Avatar asked Sep 02 '13 08:09

Ehsan88


People also ask

How do I create an empty GUID?

If you want to create an empty Guid, you can use Guid. Empty : it will return a Guid composed only by 0s, like 00000000-0000-0000-0000-000000000000.

Can a GUID be null?

A Guid is a struct , those can't be null. You need to use the nullable type.

What is the value of GUID empty?

A Guid. Empty has a value of 00000000-0000-0000-0000-000000000000. You can take advantage of an empty GUID to compare it with another GUID object to determine if it is non-zero.


1 Answers

As simple as this:

var guid = Guid.Empty;
like image 139
Matthew Watson Avatar answered Sep 20 '22 18:09

Matthew Watson