Click here to Skip to main content
15,880,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using System.Guid.NewGuid() to create new unique identifier.

Does it contains any special character like '_' (underscore)?

Thanks in advance,

Pushkar

What I have tried:

C#
int randomNumber = System.Guid.NewGuid();


Is there any possibility that it will contain "_"(underscore).
Posted
Updated 14-May-18 6:30am

Yes, a byte in a Guid could have any value between #0~#255. The string representation of a Guid is really a separate issue.

A Guid is a #16-byte, #128-bit integer.

Take a look:
Guid newGuid = Guid.NewGuid();
Byte[] bytes = newGuid.ToByteArray();
// set break-point here, examine bytes
Suggested reading: [^]
 
Share this answer
 
v4
No it won't have an underscore. If you are processing a guid as a string there are various parameters you can add to Guid.ToString to control if the hyphen or curly braces are used.

Guid.ToString Method (String) (System)[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900