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