Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Guid

0 views
Skip to first unread message

Jim Heavey

unread,
Jan 6, 2004, 7:59:57 PM1/6/04
to
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?

Paul Cooper

unread,
Jan 6, 2004, 8:36:44 PM1/6/04
to

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

>.
>

Jim Heavey

unread,
Jan 6, 2004, 9:32:36 PM1/6/04
to
I tried this method, but it returns all zeros...is there some sort of
setting that I am missing?

Roy Fine

unread,
Jan 6, 2004, 9:37:58 PM1/6/04
to
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" <JimH...@nospam.com> wrote in message
news:Xns9468C1483867CJ...@207.46.248.16...

Hadi

unread,
Jan 6, 2004, 10:01:29 PM1/6/04
to
"Jim Heavey" <JimH...@nospam.com> wrote in message
news:Xns9468D0FD15D8EJ...@207.46.248.16...

> 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


anon...@discussions.microsoft.com

unread,
Jan 12, 2004, 3:59:48 PM1/12/04
to
Im having the same problem....

returns all zeros

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


userid=00000000-0000-0000-0000-000000000000

>.
>

Chris Torgerson

unread,
Jan 12, 2004, 4:33:27 PM1/12/04
to
Code should be as follows:
Guid GUID = Guid.NewGuid();
values.Add("userid", GUID.ToString());


<anon...@discussions.microsoft.com> wrote in message
news:52de01c3d94f$039d7380$7d02...@phx.gbl...

0 new messages