Categories
asp.net c# guid

Is it good idea to remove dash from a GUID?

I have code which replaces the dash with empty strings in a GUID.

Replace(System.Guid.NewGuid.ToString, "-", "")

Would that remove the uniqueness of the guid?

Also can someone confirm this too?

We are storing GUIDs in our database as char(32). Is that okay? Because we have international users in different timezone, we’re concerned that the character length could go over 32. Thanks.

Yes, it is OK to remove the dashes. The uniqueness of the Guid is guaranteed.

Dashes are only for readability: internally the Guid is made of 16 bytes.

You can see Microsoft and Wikipedia for more details.

Take a look at constructors too:

public Guid(int a, short b, short c, byte[] d);
public Guid(int a, short b, short c, byte d,
byte e, byte f, byte g, byte h,
byte i, byte
public Guid(uint a, ushort b, ushort c, byte d,
byte e, byte f, byte g, byte h,
byte i, byte j, byte k);