Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stupid GUID tricks

Status
Not open for further replies.

BrianB

Programmer
Oct 2, 2000
186
US
Hi folks. Has anyone seen this behavior?

dim m_guid as System.Guid

m_guid = new System.Guid

In immediate window:
>? m_guid
{System.Guid}
Empty: {System.Guid}

>? m_guid.ToString()
"3c8cc630-570c-4b85-bbf7-7a5e10ea3458"

huh?? My guid doesn't have any value but when I call ToString when it magically gets a value? When I create the guid using new Guid(<<Some valid GUID>>) it exhibits the same behavior. Empty, except not.

What am I missing?

Is it something perverse about how VB.NET handles Guid's because we haven't observed this in any C# code.

Brian Begy
BugSentry - Automatic error reporting for .NET and COM
 
I'm surprised it let you construct a new Guid without any parameters. The v1.1 framework says the constructors are:
Code:
 Public Sub New(Byte())
 Public Sub New(String)
 Public Sub New(Integer, Short, Short, Byte())
 Public Sub New(Integer, Short, Short, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte)
 Public Sub New(UInt32, UInt16, UInt16, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte)
No default constructor listed. Is it possible you're picking up a Guid from a namespace other than System?

Chip H.

____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
My bad.

m_guid = System.Guid.NewGuid()


I also found that new Guid(Some valid Guid string) didn't work either. Both claim to be "empty." I'm suspecting this is some perversity in the way that the immediate window works in vb.net.

Brian Begy
BugSentry - Automatic error reporting for .NET and COM
 
Not all Guid strings are created equal. Some have curly braces and dashes, others don't.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top