473,847 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Guid.Empty

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
9 34860
"Rene" <no****@nospam. com> wrote in message
news:Ok******** *****@TK2MSFTNG P10.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************* **********@hotm ail.com
Above views may belong only to me.
Nov 16 '05 #2
"00000000-0000-0000-0000-000000000000" is in fact my custom Guid.

"Larry Brasfield" <do************ ***********@hot mail.com> wrote in message
news:e6******** *****@TK2MSFTNG P15.phx.gbl...
"Rene" <no****@nospam. com> wrote in message
news:Ok******** *****@TK2MSFTNG P10.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************* **********@hotm ail.com
Above views may belong only to me.

Nov 16 '05 #3
[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************* **********@hotm ail.com
Above views may belong only to me.

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

"Larry Brasfield" <do************ ***********@hot mail.com> wrote in message news:e6******** *****@TK2MSFTNG P15.phx.gbl...
"Rene" <no****@nospam. com> wrote in message
news:Ok******** *****@TK2MSFTNG P10.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
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************ ***********@hot mail.com> wrote in message
news:%2******** ********@tk2msf tngp13.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************* **********@hotm ail.com
Above views may belong only to me.

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

"Larry Brasfield" <do************ ***********@hot mail.com> wrote in
message news:e6******** *****@TK2MSFTNG P15.phx.gbl...
"Rene" <no****@nospam. com> wrote in message
news:Ok******** *****@TK2MSFTNG P10.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.Empt y 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
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******** ********@TK2MSF TNGP09.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************ ***********@hot mail.com> wrote in message
news:%2******** ********@tk2msf tngp13.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************* **********@hotm ail.com
Above views may belong only to me.

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

"Larry Brasfield" <do************ ***********@hot mail.com> wrote in
message news:e6******** *****@TK2MSFTNG P15.phx.gbl...
"Rene" <no****@nospam. com> wrote in message
news:Ok******** *****@TK2MSFTNG P10.phx.gbl...
>I am using the Guid.Empty value
>("000000 00-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
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*******@hotm ail.nospam.com> wrote in message
news:tt******** ************@co mcast.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******** ********@TK2MSF TNGP09.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************ ***********@hot mail.com> wrote in
message news:%2******** ********@tk2msf tngp13.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************* **********@hotm ail.com
Above views may belong only to me.

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

"Larry Brasfield" <do************ ***********@hot mail.com> wrote in
message news:e6******** *****@TK2MSFTNG P15.phx.gbl...
> "Rene" <no****@nospam. com> wrote in message
> news:Ok******** *****@TK2MSFTNG P10.phx.gbl...
>>I am using the Guid.Empty value
>>("0000000 0-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
>>reserve d 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
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******** ********@TK2MSF TNGP09.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************ ***********@hot mail.com> wrote in message
news:%2******** ********@tk2msf tngp13.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************* **********@hotm ail.com
Above views may belong only to me.

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

"Larry Brasfield" <do************ ***********@hot mail.com> wrote in
message news:e6******** *****@TK2MSFTNG P15.phx.gbl...
> "Rene" <no****@nospam. com> wrote in message
> news:Ok******** *****@TK2MSFTNG P10.phx.gbl...
>>I am using the Guid.Empty value
>>("000000 00-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
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*********@di scussions.micro soft.com> wrote in message
news:66******** *************** ***********@mic rosoft.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******** ********@TK2MSF TNGP09.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************ ***********@hot mail.com> wrote in
> message
> news:%2******** ********@tk2msf tngp13.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************* **********@hotm ail.com
>> Above views may belong only to me.
>>
>> "Rene" <no****@nospam. com> wrote in message
>> news:OI******** ******@TK2MSFTN GP09.phx.gbl...
>>> "00000000-0000-0000-0000-000000000000" is in fact my custom Guid.
>>>
>>> "Larry Brasfield" <do************ ***********@hot mail.com> wrote in
>>> message news:e6******** *****@TK2MSFTNG P15.phx.gbl...
>>>> "Rene" <no****@nospam. com> wrote in message
>>>> news:Ok******** *****@TK2MSFTNG P10.phx.gbl...
>>>>>I am using the Guid.Empty value
>>>>>("000000 00-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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1432
by: Alexander Muylaert | last post by:
Hi Does anybody has an idea how to have guids, created on many computers, sorted by Timestamp? It doesn't have to be very accurate, but it would mean a great optimization for my datastructures. I made a small testroutine and I have a 50% chance that the new guid is smaller than the guid created a second before on 1 computer. Any idea is appreciated.
5
13721
by: George | last post by:
I want to create a unique id for each of a set of objects. These ids may be generated on multiple machines simultaneously and must all be different to each other. There are an undefined number of machines involved (1 to dozens) and an indeterminate number of objects (many to very many on each machine). My best guess for a solution would be to use a GUID (all the machines have an ethernet connection so a GUID generated on any of them...
2
4260
by: csharper | last post by:
Why does Guid.GetHashcode() returns 0 when instantiated with Guid.Empty ?
8
3199
by: Pohihihi | last post by:
I guess I am forgetting some rules, why I am not able to do following, says it is read only -- Guid a = new Guid; foreach(Guid b in a) b = Guid.Empty; but can do as following -- int c = 0;
10
4399
by: Charles Hunt | last post by:
Hi, When running this code in VB2003 Sub guidtest() Dim gstring As String Dim gid As Guid
5
6506
by: Michael Primeaux | last post by:
I have a simple .NET 2.0 web service created with VS.NET 2005 with a single web method with the following signature: void HelloWorld(Guid parameter1); When calling this method I receive the following error: System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Web.Services.Protocols.HttpServerType..ctor(Type type) at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
2
332
by: newbienew | last post by:
What is the maximum value of a GUID... is it possible to get the maximum value from a method or property like Guid.Empty?
3
7348
by: Ronald S. Cook | last post by:
I have a function in which I'm trying to make the parameter optional. However, when I put Optional in front of ByVal below I get the error "optional parameters cannot have structure types". Public Function SelectPenType(ByVal PenTypeID As Guid) As DataSet Implements IPen.SelectPenType Any idea how I should be doing this? Thanks,
7
23401
by: Peter K | last post by:
Hi - should the following compile? I ask because a Guid is a struct and can never be null... The worst the compiler throws at me is an "unreachable code" warning. public string GetData(Guid id) { if (id == null) throw new ArgumentNotNullException(""); string s = null;
0
9733
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10715
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10346
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9489
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7887
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7060
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5724
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4126
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.