字符代码
生成字符串:
private string GenerateId()
{
long i = 1;
foreach (byte b in Guid.NewGuid().ToByteArray())
{
i *= ((int)b + 1);
}
return string.Format("{0:x}", i - DateTime.Now.Ticks);
}
生成数字:
private long GenerateId1()
{
byte[] buffer = Guid.NewGuid().ToByteArray();
return BitConverter.ToInt64(buffer, 0);
}
按时间生成:
String.Format("{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmss"),Guid.NewGuid().ToString().Split('-')[4]);
---------------------
作者:sz_bdqn
来源:CSDN
原文:https://blog.csdn.net/sz_bdqn/article/details/5878476
版权声明:本文为博主原创文章,转载请附上博文链接!
网友评论