一个生成 N 位随机数字的方法
呵呵 大家一起研究阿!!!!!
/// </summary>
/// <param name="n">生成长度为 n </param>
/// <returns></returns>
public static string RandNum()
{
char[] arrChar = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
StringBuilder num = new StringBuilder();
Random rnd = new Random(DateTime.Now.Millisecond);
for (int i = 0; i < n; i++)
{
num.Append(arrChar[rnd.Next(0, 9)].ToString());
}
return num.ToString();
}
/// </summary>
/// <param name="n">生成长度为 n </param>
/// <returns></returns>
public static string RandNum()
{
char[] arrChar = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
StringBuilder num = new StringBuilder();
Random rnd = new Random(DateTime.Now.Millisecond);
for (int i = 0; i < n; i++)
{
num.Append(arrChar[rnd.Next(0, 9)].ToString());
}
return num.ToString();
}