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 said:
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 said:
[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: (e-mail address removed)
Above views may belong only to me.
"00000000-0000-0000-0000-000000000000" is in fact my custom Guid.
message 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.