Monday, November 03, 2008

C# quiz 9/?

Consider the following:

Guid globallyUnique1 = new Guid();
Guid globallyUnique2 = new Guid();
if (globallyUnique1 == globallyUnique2)
MessageBox.Show("This cannot be");
MessageBox.Show("Everything is well");

What is shown? Why?

1 comment:

Nicolas Jolet said...

"This cannot be"
because "new Guid()" create only an object Guid initialized to Guid.Empty.
If you want to have a new intialized and unique Guid, you need to use the Guid.NewGuid() static method.