The default value for int
is 0 , for string
is "" and for boolean
it is false. Could someone please clarify what the default value for guid
is?
-
58default `Guid` is `{00000000-0000-0000-0000-000000000000}`. It's basically binary zeroes. – Szer Jun 22 '15 at 10:32
-
related question [How can I default a parameter to Guid.Empty in C#?](//stackoverflow.com/q/5117970) – Michael Freidgeim Nov 19 '17 at 11:52
-
3This website can supply empty guids http://00000000-0000-0000-0000-000000000000.com/ – Matthew Jan 04 '18 at 02:23
-
2As a side note: the default value of strings is null, not "" (; – Johan Wintgens Apr 23 '20 at 07:34
5 Answers
You can use these methods to get an empty guid. The result will be a guid with all it's digits being 0's - "00000000-0000-0000-0000-000000000000
".
new Guid()
default(Guid)
Guid.Empty
As Use Keim points out in the comments default
is short for default(Guid)

- 16,474
- 7
- 46
- 63
-
4In newer C# versions, `default(Guid)` and `default` are the same, too. – Uwe Keim Aug 03 '21 at 16:05
-
Guid.Empty can't be used as a compile time constant. So you can't use it to default a parameter. – JSWilson Sep 10 '21 at 13:55
You can use Guid.Empty
. It is a read-only instance of the Guid structure with the value of 00000000-0000-0000-0000-000000000000
you can also use these instead
var g = new Guid();
var g = default(Guid);
beware not to use Guid.NewGuid()
because it will generate a new Guid.
use one of the options above which you and your team think it is more readable and stick to it. Do not mix different options across the code. I think the Guid.Empty
is the best one since new Guid()
might make us think it is generating a new guid and some may not know what is the value of default(Guid)
.

- 1
- 1

- 20,441
- 9
- 58
- 74
The default value for a GUID is empty. (eg: 00000000-0000-0000-0000-000000000000)
This can be invoked using Guid.Empty
or new Guid()
If you want a new GUID, you use Guid.NewGuid()

- 3,668
- 1
- 21
- 32

- 2,249
- 22
- 33
-
9@anchor I've noticed that you have never accepted any answer to your questions. [Here - in the FAQ of StackExchange](http://meta.stackexchange.com/q/5234) you can read how you can accept an answer and why you should do that. – Genhis Jul 20 '15 at 04:47
-
3@Genhis I think he got what he needed and then dropped of the face of the earth haha – David Watts Feb 14 '19 at 16:33
To extend answers above, you cannot use Guid default value with Guid.Empty
as an optional argument in method, indexer or delegate definition, because it will give you compile time error. Use default(Guid)
or new Guid()
instead.

- 2,282
- 3
- 24
- 28
You can create an Empty Guid or New Guid using a class.
The default value of Guid is 00000000-0000-0000-0000-000000000000
public class clsGuid // This is a class name
{
public Guid MyGuid { get; set; }
}
static void Main(string[] args)
{
clsGuid cs = new clsGuid();
Console.WriteLine(cs.MyGuid); // This will give empty Guid "00000000-0000-0000-0000-000000000000"
cs.MyGuid = new Guid();
Console.WriteLine(cs.MyGuid); // This will also give empty Guid "00000000-0000-0000-0000-000000000000"
cs.MyGuid = Guid.NewGuid();
Console.WriteLine(cs.MyGuid); // This way, it will give a new Guid (eg. "d94828f8-7fa0-4dd0-bf91-49d81d5646af")
Console.ReadKey(); // This line holds the output screen in a console application
}

- 2,590
- 1
- 18
- 31

- 1,476
- 1
- 8
- 18
-
yes...you can make the class value as static value...or using that in class.. – THE LIFE-TIME LEARNER Jan 10 '20 at 06:11
-
1I know we can use Guid as we can use any other type in C#. My question was, whether your answer contains any new information that wasn't here before. It seems all the information you posted was already posted by multiple other people years ago. – nvoigt Jan 10 '20 at 06:13
-
yes...u r right...i telling that...u can use empty guid and new guid using a class...that type of answer is not present...in this question... – THE LIFE-TIME LEARNER Jan 10 '20 at 06:24
-
1Formatting could be improved, specifically the comments should start with //. Otherwise this is a good answer as it specifically displays usage in a custom class. – The Thirsty Ape Aug 13 '21 at 16:09