Guid

  • Thread starter Thread starter Jim Heavey
  • Start date Start date
J

Jim Heavey

When I use the new(Guid), the GUID which is generated is all zeros. Is
there a technique for the system to assign a real Guid? Do I have to
manually calculate a GUID?
 
When you need the system to generate a new Guid there is a
static member of the Guid class that allows you to do this.

Try:
uidTest = Guid.NewGuid()

Regards
Paul
 
I tried this method, but it returns all zeros...is there some sort of
setting that I am missing?
 
Jim

each of these:
System.Guid x = new System.Guid();
System.Guid x;
will create an instance of a Guid type (the first will be initialized by the
default ctor, the second will be uninitialized) - and as you reported, the
default initialized value is set to all zeros. To get a value that is
globally unique in time and space, use the static NewGuid() method.
Something like this:

System.Guid x = System.Guid.NewGuid();
or
System.Guid x;
....
x = System.Guid.NewGuid();

regards
roy fine
 
Jim Heavey said:
I tried this method, but it returns all zeros...is there some sort of
setting that I am missing?

Odd that;s really how people creates new GUID, are you sure you are checking
the right variable etc?

Hadi
 
Im having the same problem....

returns all zeros

Guid GUID = new Guid();
values.Add("userid", GUID.ToString());


userid=00000000-0000-0000-0000-000000000000
 
Code should be as follows:
Guid GUID = Guid.NewGuid();
values.Add("userid", GUID.ToString());
 
Back
Top