Code
Something = new Guid()
is returning
00000000-0000-0000-0000-000000000000
all the time and I can't tell why? so, why?
Code
Something = new Guid()
is returning
00000000-0000-0000-0000-000000000000
all the time and I can't tell why? so, why?
Just a quick explanation for why you need to call NewGuid as opposed to using the default constructor... In .NET all structures (value types like int, decimal, Guid, DateTime, etc) must have a default parameterless constructor that initializes all of the fields to their default value. In the case of Guid, the bytes that make up the Guid are all zero. Rather than making a special case for Guid or making it a class, they use the NewGuid method to generate a new "random" Guid.
It's in System.Guid.
To dynamically create a GUID in code:
Guid messageId = System.Guid.NewGuid();
To see its value:
string x = messageId.ToString();