偶尔在网上看到的,相对比较好的c#端订单号生成规则
public class BillNumberBuilder{ private static object locker = new object(); private static int sn = 0; public static string NextBillNumber(){ lock(locker){ if(sn == 9999999999) sn = 0; else sn++; return DateTime.Now.ToString("yyyyMMddHHmmss") + sn.ToString().PadLeft(10, ‘0‘); } } // 防止创建类的实例 private BillNumberBuilder(){} }
原文地址:http://www.cnblogs.com/cxd4321/p/3812113.html