Is it good idea to remove dash from a GUID?

Salman picture Salman · Oct 20, 2011 · Viewed 14.9k times · Source

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.

Answer

tonycoupland picture tonycoupland · Oct 20, 2011

The dashes are always in the same place, so no, it will not reduce the uniqueness.

System.Guid.NewGuid().ToString("N");

Will generate a GUID without dashes, as in this documentation