CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of Unique Id
C#
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>
by Rick Strahl   October 09, 2011 @ 8:01pm
192 Views
1 comments
 
C#
/// <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
by Rick Strahl   July 09, 2009 @ 4:21pm
282 Views
no comments
 
C#
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();
by Peter Bromberg   July 09, 2009 @ 2:34pm
Tags: UNIQUE ID
161 Views
no comments
 
C#
  /// <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));            
  }
by Rick Strahl   July 09, 2009 @ 2:23pm
Tags: C#, Unique Id, Guid
268 Views
no comments
 
C#
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++) {
by Rick Strahl   July 09, 2009 @ 1:21pm
Tags: C#, Guid, Unique Id
223 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate