Format:
Recent snippets matching tags of Unique Id
public class ObjectFactory<T> where T: class, new() { ... /// <summary> /// Returns a unique ID for a given type and parameter signature /// </summary> /// <typeparam name="T"></typeparam>
192 Views
1 comments
/// <summary> /// Generates a unique Id as a string of up to 16 characters. /// Based on a GUID and the size takes that subset of a the /// Guid's 16 bytes to create a string id. /// /// String Id contains numbers and lower case alpha chars 36 total. /// /// Sizes: 6 gives roughly 99.97% uniqueness. /// 8 gives less than 1 in a million doubles. /// 16 will give full GUID strength uniqueness
282 Views
no comments
public static string GetUniqueKey() { int maxSize = 4; char[] chars = new char[62]; string a; a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; chars = a.ToCharArray(); int size = maxSize; byte[] data = new byte[1]; RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
161 Views
no comments
/// <summary> /// Generates a unique Id as string /// </summary> /// <returns></returns> public static string GenerateUniqueId() { byte[] bytes = Guid.NewGuid().ToByteArray(); return StringUtils.Base36Encode(BitConverter.ToInt64(bytes, 0)); }
268 Views
no comments
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++) {
223 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
