c# 生成随机N位数字串(每位可以重复)
/// <summary> /// 生成随机数字窜 /// </summary> /// <param name="Digit">位数</param> /// <returns></returns> private string RandomNum(int Digit) { StringBuilder sb = new StringBuilder(); Random random = new Random(); int Nums = Digit; while (Nums > 0) { int i = random.Next(1, 10);// 9>=a>=1 if (sb.Length < Digit) { sb.Append(i); } Nums -= 1; } return sb.ToString(); }