By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,276 Members | 1,951 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,276 IT Pros & Developers. It's quick & easy.

Guid.Empty

P: n/a
I am using the Guid.Empty value ("00000000-0000-0000-0000-000000000000") to
represent a special meaning. The problem is that I don't know if there is a
chance that a command like "Guid.NewGuid()"would generate a Guid.Empty value
could this be possible or is the "00000000-0000-0000-0000-000000000000" Guid
reserved or something like that?

Thank you.

Nov 16 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
"Rene" <no****@nospam.com> wrote in message
news:Ok*************@TK2MSFTNGP10.phx.gbl...
I am using the Guid.Empty value ("00000000-0000-0000-0000-000000000000") to represent a special meaning. The problem is that I
don't know if there is a chance that a command like "Guid.NewGuid()"would generate a Guid.Empty value could this be possible or is
the "00000000-0000-0000-0000-000000000000" Guid reserved or something like that?

Why not use a custom GUID for your special meaning?
The chances of a collision with some other GUID are
very very small. Remember, that low probability is
the whole reason GUID are in common use.

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.
Nov 16 '05 #2

P: n/a
"00000000-0000-0000-0000-000000000000" is in fact my custom Guid.

"Larry Brasfield" <do***********************@hotmail.com> wrote in message
news:e6*************@TK2MSFTNGP15.phx.gbl...
"Rene" <no****@nospam.com> wrote in message
news:Ok*************@TK2MSFTNGP10.phx.gbl...
I am using the Guid.Empty value ("00000000-0000-0000-0000-000000000000")
to represent a special meaning. The problem is that I don't know if there
is a chance that a command like "Guid.NewGuid()"would generate a
Guid.Empty value could this be possible or is the
"00000000-0000-0000-0000-000000000000" Guid reserved or something like
that?

Why not use a custom GUID for your special meaning?
The chances of a collision with some other GUID are
very very small. Remember, that low probability is
the whole reason GUID are in common use.

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.

Nov 16 '05 #3

P: n/a
[top-posting maintained for inclarity]

To maximize the probability of a collision with some other
non-randomly generated "GUID", you could not choose
a better value than the one you propose.

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.

"Rene" <no****@nospam.com> wrote in message news:OI**************@TK2MSFTNGP09.phx.gbl...
"00000000-0000-0000-0000-000000000000" is in fact my custom Guid.

"Larry Brasfield" <do***********************@hotmail.com> wrote in message news:e6*************@TK2MSFTNGP15.phx.gbl...
"Rene" <no****@nospam.com> wrote in message
news:Ok*************@TK2MSFTNGP10.phx.gbl...
I am using the Guid.Empty value ("00000000-0000-0000-0000-000000000000") to represent a special meaning. The problem is that I
don't know if there is a chance that a command like "Guid.NewGuid()"would generate a Guid.Empty value could this be possible or
is the "00000000-0000-0000-0000-000000000000" Guid reserved or something like that?

Why not use a custom GUID for your special meaning?
The chances of a collision with some other GUID are
very very small. Remember, that low probability is
the whole reason GUID are in common use.

Nov 16 '05 #4

P: n/a
All I really want to know is what are the chances that Guid.NewGuid() will
create a 00000000-0000-0000-0000-000000000000 value? What would it take for
the function to create such value?
"Larry Brasfield" <do***********************@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
[top-posting maintained for inclarity]

To maximize the probability of a collision with some other
non-randomly generated "GUID", you could not choose
a better value than the one you propose.

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.

"Rene" <no****@nospam.com> wrote in message
news:OI**************@TK2MSFTNGP09.phx.gbl...
"00000000-0000-0000-0000-000000000000" is in fact my custom Guid.

"Larry Brasfield" <do***********************@hotmail.com> wrote in
message news:e6*************@TK2MSFTNGP15.phx.gbl...
"Rene" <no****@nospam.com> wrote in message
news:Ok*************@TK2MSFTNGP10.phx.gbl...
I am using the Guid.Empty value ("00000000-0000-0000-0000-000000000000")
to represent a special meaning. The problem is that I don't know if
there is a chance that a command like "Guid.NewGuid()"would generate a
Guid.Empty value could this be possible or is the
"00000000-0000-0000-0000-000000000000" Guid reserved or something like
that?
Why not use a custom GUID for your special meaning?
The chances of a collision with some other GUID are
very very small. Remember, that low probability is
the whole reason GUID are in common use.


Nov 16 '05 #5

P: n/a
Guid.NewGuid() will return a string of zeros exactly as often as it will
return the value: {2C948FCC-035F-4a98-866E-4C9DF5FA7984}... which is very
remote indeed.

However, another developer may make the same mistake you are making, and
assume that their app is not running on the same machine as your app, and
that therefore, a string of zeros is a safe number. Statistically speaking,
that condition is far more likely than the possibility of Guid.NewGuid()
creating a duplicate number.

You are MUCH better off simply generating a GUID and using it. Then, you
are less likely to run into another programmer with a penchant for guessing
a random number.

This is precisely what Larry was trying to say.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Rene" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
All I really want to know is what are the chances that Guid.NewGuid() will
create a 00000000-0000-0000-0000-000000000000 value? What would it take
for the function to create such value?
"Larry Brasfield" <do***********************@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
[top-posting maintained for inclarity]

To maximize the probability of a collision with some other
non-randomly generated "GUID", you could not choose
a better value than the one you propose.

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.

"Rene" <no****@nospam.com> wrote in message
news:OI**************@TK2MSFTNGP09.phx.gbl...
"00000000-0000-0000-0000-000000000000" is in fact my custom Guid.

"Larry Brasfield" <do***********************@hotmail.com> wrote in
message news:e6*************@TK2MSFTNGP15.phx.gbl...
"Rene" <no****@nospam.com> wrote in message
news:Ok*************@TK2MSFTNGP10.phx.gbl...
>I am using the Guid.Empty value
>("00000000-0000-0000-0000-000000000000") to represent a special
>meaning. The problem is that I don't know if there is a chance that a
>command like "Guid.NewGuid()"would generate a Guid.Empty value could
>this be possible or is the "00000000-0000-0000-0000-000000000000" Guid
>reserved or something like that?
Why not use a custom GUID for your special meaning?
The chances of a collision with some other GUID are
very very small. Remember, that low probability is
the whole reason GUID are in common use.



Nov 16 '05 #6

P: n/a
Thanks Nick.

I understood what Larry was saying, I was more curious than anything else,
you see, as you know, the Guid has a specific property called Empty that
represents the 0000...., that's why I was thinking that maybe the 0000....
was reserved for that special purpose (kind of like null in databases to
represent nothing) and it was impossible to get it though Guid.NewGuid().

Plain curiosity.


"Nick Malik [Microsoft]" <ni*******@hotmail.nospam.com> wrote in message
news:tt********************@comcast.com...
Guid.NewGuid() will return a string of zeros exactly as often as it will
return the value: {2C948FCC-035F-4a98-866E-4C9DF5FA7984}... which is very
remote indeed.

However, another developer may make the same mistake you are making, and
assume that their app is not running on the same machine as your app, and
that therefore, a string of zeros is a safe number. Statistically
speaking, that condition is far more likely than the possibility of
Guid.NewGuid() creating a duplicate number.

You are MUCH better off simply generating a GUID and using it. Then, you
are less likely to run into another programmer with a penchant for
guessing a random number.

This is precisely what Larry was trying to say.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Rene" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
All I really want to know is what are the chances that Guid.NewGuid()
will create a 00000000-0000-0000-0000-000000000000 value? What would it
take for the function to create such value?
"Larry Brasfield" <do***********************@hotmail.com> wrote in
message news:%2****************@tk2msftngp13.phx.gbl...
[top-posting maintained for inclarity]

To maximize the probability of a collision with some other
non-randomly generated "GUID", you could not choose
a better value than the one you propose.

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.

"Rene" <no****@nospam.com> wrote in message
news:OI**************@TK2MSFTNGP09.phx.gbl...
"00000000-0000-0000-0000-000000000000" is in fact my custom Guid.

"Larry Brasfield" <do***********************@hotmail.com> wrote in
message news:e6*************@TK2MSFTNGP15.phx.gbl...
> "Rene" <no****@nospam.com> wrote in message
> news:Ok*************@TK2MSFTNGP10.phx.gbl...
>>I am using the Guid.Empty value
>>("00000000-0000-0000-0000-000000000000") to represent a special
>>meaning. The problem is that I don't know if there is a chance that a
>>command like "Guid.NewGuid()"would generate a Guid.Empty value could
>>this be possible or is the "00000000-0000-0000-0000-000000000000" Guid
>>reserved or something like that?
>
>
> Why not use a custom GUID for your special meaning?
> The chances of a collision with some other GUID are
> very very small. Remember, that low probability is
> the whole reason GUID are in common use.



Nov 16 '05 #7

P: n/a
Shouldn't a completely zero guid be impossible to get from Guid.NewGuid() as
between the variant and version fields there ought to be at least one bit
set? Or am I mistaken in thinking Guids follow a standard format
(http://www.webdav.org/specs/draft-le...guids-01.txt)?
I don't argue the point that Guid.Empty should be used with care to avoid
collision due to its being used as a sentinel by other developers, but I
don't think you should need to worry about it colliding with
machine-generated values.
Just curious.

"Nick Malik [Microsoft]" wrote:
Guid.NewGuid() will return a string of zeros exactly as often as it will
return the value: {2C948FCC-035F-4a98-866E-4C9DF5FA7984}... which is very
remote indeed.

However, another developer may make the same mistake you are making, and
assume that their app is not running on the same machine as your app, and
that therefore, a string of zeros is a safe number. Statistically speaking,
that condition is far more likely than the possibility of Guid.NewGuid()
creating a duplicate number.

You are MUCH better off simply generating a GUID and using it. Then, you
are less likely to run into another programmer with a penchant for guessing
a random number.

This is precisely what Larry was trying to say.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Rene" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
All I really want to know is what are the chances that Guid.NewGuid() will
create a 00000000-0000-0000-0000-000000000000 value? What would it take
for the function to create such value?
"Larry Brasfield" <do***********************@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
[top-posting maintained for inclarity]

To maximize the probability of a collision with some other
non-randomly generated "GUID", you could not choose
a better value than the one you propose.

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.

"Rene" <no****@nospam.com> wrote in message
news:OI**************@TK2MSFTNGP09.phx.gbl...
"00000000-0000-0000-0000-000000000000" is in fact my custom Guid.

"Larry Brasfield" <do***********************@hotmail.com> wrote in
message news:e6*************@TK2MSFTNGP15.phx.gbl...
> "Rene" <no****@nospam.com> wrote in message
> news:Ok*************@TK2MSFTNGP10.phx.gbl...
>>I am using the Guid.Empty value
>>("00000000-0000-0000-0000-000000000000") to represent a special
>>meaning. The problem is that I don't know if there is a chance that a
>>command like "Guid.NewGuid()"would generate a Guid.Empty value could
>>this be possible or is the "00000000-0000-0000-0000-000000000000" Guid
>>reserved or something like that?
>
>
> Why not use a custom GUID for your special meaning?
> The chances of a collision with some other GUID are
> very very small. Remember, that low probability is
> the whole reason GUID are in common use.



Nov 16 '05 #8

P: n/a
My mistake. You are correct. an all-zero GUID is not possible from
Guid.NewGuid().

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Jeremy Davis" <Je*********@discussions.microsoft.com> wrote in message
news:66**********************************@microsof t.com...
Shouldn't a completely zero guid be impossible to get from Guid.NewGuid()
as
between the variant and version fields there ought to be at least one bit
set? Or am I mistaken in thinking Guids follow a standard format
(http://www.webdav.org/specs/draft-le...guids-01.txt)?
I don't argue the point that Guid.Empty should be used with care to avoid
collision due to its being used as a sentinel by other developers, but I
don't think you should need to worry about it colliding with
machine-generated values.
Just curious.

"Nick Malik [Microsoft]" wrote:
Guid.NewGuid() will return a string of zeros exactly as often as it will
return the value: {2C948FCC-035F-4a98-866E-4C9DF5FA7984}... which is very
remote indeed.

However, another developer may make the same mistake you are making, and
assume that their app is not running on the same machine as your app, and
that therefore, a string of zeros is a safe number. Statistically
speaking,
that condition is far more likely than the possibility of Guid.NewGuid()
creating a duplicate number.

You are MUCH better off simply generating a GUID and using it. Then, you
are less likely to run into another programmer with a penchant for
guessing
a random number.

This is precisely what Larry was trying to say.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Rene" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> All I really want to know is what are the chances that Guid.NewGuid()
> will
> create a 00000000-0000-0000-0000-000000000000 value? What would it take
> for the function to create such value?
>
>
> "Larry Brasfield" <do***********************@hotmail.com> wrote in
> message
> news:%2****************@tk2msftngp13.phx.gbl...
>> [top-posting maintained for inclarity]
>>
>> To maximize the probability of a collision with some other
>> non-randomly generated "GUID", you could not choose
>> a better value than the one you propose.
>>
>> --
>> --Larry Brasfield
>> email: do***********************@hotmail.com
>> Above views may belong only to me.
>>
>> "Rene" <no****@nospam.com> wrote in message
>> news:OI**************@TK2MSFTNGP09.phx.gbl...
>>> "00000000-0000-0000-0000-000000000000" is in fact my custom Guid.
>>>
>>> "Larry Brasfield" <do***********************@hotmail.com> wrote in
>>> message news:e6*************@TK2MSFTNGP15.phx.gbl...
>>>> "Rene" <no****@nospam.com> wrote in message
>>>> news:Ok*************@TK2MSFTNGP10.phx.gbl...
>>>>>I am using the Guid.Empty value
>>>>>("00000000-0000-0000-0000-000000000000") to represent a special
>>>>>meaning. The problem is that I don't know if there is a chance that
>>>>>a
>>>>>command like "Guid.NewGuid()"would generate a Guid.Empty value could
>>>>>this be possible or is the "00000000-0000-0000-0000-000000000000"
>>>>>Guid
>>>>>reserved or something like that?
>>>>
>>>>
>>>> Why not use a custom GUID for your special meaning?
>>>> The chances of a collision with some other GUID are
>>>> very very small. Remember, that low probability is
>>>> the whole reason GUID are in common use.
>>
>>
>
>


Nov 16 '05 #9

P: n/a

Guid.Empty is special but only int he context of .NET.

Guid is a value type and as such can not be null. Therefore, whenever
you declare a variable of type Guid that variable is automatically
initialized to a zero value. Since Guid isn't nullable, you can't
check if it's null. Therefore, to check if a Guid has been
initialized to a real generated Guid value compare it to Guid.Empty.

So instead of

// generates error...
if (myGuid != null) {
}

you use

if (myGuid != Guid.Empty) {
}

So Guid.Empty does have special meaning equivalent to a null value for
a reference type. That should be reason enough not to use it in your
app for some other purpose (besides the reasons already
mentioned--collision with another developer making the same assumption
as you).

HTH,

Sam

On Fri, 4 Mar 2005 02:04:01 -0600, "Rene" <no****@nospam.com> wrote:
Thanks Nick.

I understood what Larry was saying, I was more curious than anything else,
you see, as you know, the Guid has a specific property called Empty that
represents the 0000...., that's why I was thinking that maybe the 0000....
was reserved for that special purpose (kind of like null in databases to
represent nothing) and it was impossible to get it though Guid.NewGuid().

Plain curiosity.

B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
Nov 16 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.