不重复验证码

 1 string s ="1234567890zxcvbnmasdfghjklqwertyuiopZXCVBNMASDFGHJKLQWERTYUIOP";
 2 string str="";
 3 Radom rand =new Random();//初始化随机数
 4 string[]arr=new string[4];
 5 for (int i=0;i<4;i++)‫
 6 {
 7 arr[i] =rand.Next(62);//生成一个随机数的起始位置
 8 int cont=0;
 9 if(i>0)
10 {
11 for(int j=0;j<i;j++)
12 {
13 if(arr[i]==arr[j])
14 {
15 count++;
16 }
17 }
18 }
19 if(count>0)
20 {
21 i--;
22 continue;
23 }
View Code
原文地址:https://www.cnblogs.com/zxm1002/p/4968428.html