What's the difference between Guid.NewGuid() and new Guid()?
Which one is preferred?
What's the difference between Guid.NewGuid() and new Guid()?
Which one is preferred?
Guid.NewGuid() initializes a new instance of the Guid structure.
Example:
Guid g = Guid.NewGuid();
Console.WriteLine(g);
// This code example produces a result similar to the following:
// 0f8fad5b-d9cb-469f-a165-70867728950e
The method creates a Version 4 Universally Unique Identifier (UUID) as described in RFC 4122, Sec. 4.4
Also as mentioned in the official document,
The returned Guid is guaranteed to not equal Guid.Empty.