产生字符串:(例:49f949d735f5c79e)
privatestring GenerateId() { long i =1; foreach (byte b in Guid.NewGuid().ToByteArray()) { i *= ((int)b +1); } returnstring.Format("{0:x}", i - DateTime.Now.Ticks); }
产生Int64 类型:(例:4833055965497820814)
privatelong GenerateId() { byte[] buffer = Guid.NewGuid().ToByteArray(); return BitConverter.ToInt64(buffer, 0); }