Language: C#
Generating a unique ID as a string from a GUID
List<long> list = new List<long>(); byte[] bytes = Guid.NewGuid().ToByteArray(); long val = BitConverter.ToInt64(bytes,0); val.Dump(); val.ToString("x").Dump(); val.ToString("x").Length.Dump(); for(int i=0; i<1000000; i++) { bytes = Guid.NewGuid().ToByteArray(); list.Add((long) BitConverter.ToInt64(bytes,0)); } list.Distinct().Count().Dump();
Tags:
Description:
Generating a unique ID from a string. Better yet - encode with Base36 to reduce string to 12/13 chars.
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

