1 方法:
2 public string RndNum(int VcodeNum)
3 {
4 string Vchar = "0,1,2,3,4,5,6,7,8,9";
5 string[] VcArray = Vchar.Split(new Char[] { ',' });
6 string VNum = "";
7 //int temp = -1;
8 Random rand = new Random();
9 for (int i = 1; i < VcodeNum + 1; i++)
10 {
11 int t = rand.Next(10);
12 VNum += VcArray[t];
13 }
14 return VNum;
15 }
16 调用:string str = RndNum(4)