string str = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
Random ran = new Random();
int r = ran.Next(0, str.Length);
string a = str.Substring(r, 1);
用循环来选择验证码的位数:
string y = "";
Random ran = new Random();
for (int x = 1; x < 5; x++)
{
int r = ran.Next(0, str.Length);
string a = str.Substring(r, 1);
y = y + a;
}