一个序列号生成器
public string CreateSerialNumber(int strLength) { if (strLength < 1) strLength = 4; string str = string.Empty; string codeStr = string.Empty; string guidStr = Guid.NewGuid().ToString().Replace("-", ""); int guidStrLen = guidStr.Length; Random rnd = new Random(int.Parse(DateTime.Now.ToString("MMddHHmmsss"))); for (int i = 0; i < strLength; i++) { int index = rnd.Next(0, guidStrLen - 1); str += guidStr.Substring(index, 1); } return str.ToUpper(); }
版权声明:本文为youngerliu原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。