I have a problem with Guid using c#, in my application, all field of type GUID were returned '{00000000-0000-0000-0000-000000000000}'.
How do I can to resolve the problem?
If need, I would put code.
I have a problem with Guid using c#, in my application, all field of type GUID were returned '{00000000-0000-0000-0000-000000000000}'.
How do I can to resolve the problem?
If need, I would put code.
The default value of Guid
is {00000000-0000-0000-0000-000000000000}
As I consider you are using constuctor of Guid and you are getting a default value of Guid.
var g = new Guid();
In this example g
equals to the default value of guid
and equals {00000000-0000-0000-0000-000000000000}
.
In order to generate guid
you should use Guid.NewGuid
method.
var g = Guid.NewGuid();
You need to use NewGuid method
Guid.NewGuid()
As per msdn
This is a convenient static method that you can call to get a new Guid. The method wraps a call to the Windows CoCreateGuid function. The returned Guid is guaranteed to not equal Guid.Empty.