Languages
[Edit]
EN

C# / .NET - create GUID value

4 points
Created by:
Veer-Ahmad
487

In C# / .NET it is possible to create GUID / UUID (Globally Unique Identifier / Universally Unique Identifier) in the following way.

1. Guid.NewGuid + Giud.ToString methods example

Edit

Output:

2. Guid.NewGuid + Guid.ToByteArray methods example

Edit

Output:

3. Custom GUID example

Edit

Output:

Note: order of first 8 bytes is different than in string. It is caused of Microsoft GUID implementation and Little-endian of x86 processors compatibility:
It means DWORD and WORD bytes are reversed.

3. References

Edit
  1. Guid.NewGuid Method - Microsoft Docs
  2. Endianness - Wikipedia
  3. GUID Struct - Microsoft Docs
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join