c#唯一订单号生成代码
2021-05-12 13:28
标签:menu get line order pen blog write log ons c#唯一订单号生成代码 标签:menu get line order pen blog write log ons 原文地址:http://www.cnblogs.com/kwm672225801/p/7572900.htmlusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string uniqueNum = GenerateOrderNumber();
Console.WriteLine("唯一码:{0}\t 长度为:{1}", uniqueNum, uniqueNum.Length);
//测试是否会生成重复
Console.WriteLine("时间+RNGCryptoServiceProvider()结合生成的唯一值,如下:");
string _tempNum = string.Empty;
for (int i = 0; i 1000; i++)
{
string uNum = GenerateOrderNumber();
Console.WriteLine(uNum);
if (string.Equals(uNum, _tempNum))
{
Console.WriteLine("上值存在重复,按Enter键继续");
Console.ReadKey();
}
//Sleep当前线程,是为了延时,从而不产生重复值。可以把它注释掉测试看
Thread.Sleep(300);
_tempNum = uNum;
}
}
///