GUID converted to 16-bit string or 19-bit unique string

Source: Internet
Author: User
Tags string methods

Organize several common GUIDs into 16-bit strings or 19-bit unique string methods:

        //   <summary>         ///   16-bit unique string based on GUID          ///Author: Hui Yifang        //   </summary>         ///   <param name=\ "guid\" ></param>         ///   <returns></returns>          Public Static string guidto16string()        {Longi =1;foreach(byteBinchGuid.NewGuid (). Tobytearray ()) I *= ((int) B +1);return string. Format ("{0:x}", i-datetime.now.ticks); }//   <summary>         ///   19-bit unique sequence of numbers based on GUID          ///Author: Hui Yifang        //   </summary>         ///   <returns></returns>          Public Static Long Guidtolongid()        {byte[] buffer = Guid.NewGuid (). Tobytearray ();returnBitconverter.toint64 (Buffer,0); }//   <summary>         ///   generate 22-bit unique digits concurrently available          ///Author: Hui Yifang        //   </summary>         ///   <returns></returns>          Public Static string Generateuniqueid() {System.Threading.Thread.Sleep (1);//Guaranteed YYYYMMDDHHMMSSFFFF uniqueRandom d =NewRandom (Bitconverter.toint32 (GUID.NEWGUID). Tobytearray (),0));stringStrunique = DateTime.Now.ToString ("YYYYMMDDHHMMSSFFFF") + D.next ( +,9999);returnStrunique; }//   <summary>         ///   generate 22-bit unique digits concurrently available          ///Author: Hui Yifang        //   </summary>         ///   <returns></returns>          Public Static string Generateuniqueid() {System.Threading.Thread.Sleep (1);//Guaranteed YYYYMMDDHHMMSSFFFF uniqueRandom d =NewRandom (Bitconverter.toint32 (GUID.NEWGUID). Tobytearray (),0));stringStrunique = DateTime.Now.ToString ("YYYYMMDDHHMMSSFFFF") + D.next ( +,9999);returnStrunique; }

Hope that the above share of the beginner friends some help, thank you!
More Attention Fuyi Technology blog: Http://blog.csdn.net/fuyifang
or scan the QR code directly with your phone to see more Posts:

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced, more attention Fuyi technology blog: Http://blog.csdn.net/fuyifang

GUID converted to 16-bit string or 19-bit unique string

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.