有时需要一个随时间递增的随机数,一下这个算法比较好:
public static string GenerateOutTradeNo()
{var ran = new Random();
return string.Format("{0}{1}{2}", WxPayConfig.MCHID, DateTime.Now.ToString("yyyyMMddHHmmss"), ran.Next(999));
}
非递增:
public static string GenerateNonceStr()
{
return Guid.NewGuid().ToString().Replace("-", "");
}