生成6位随机字符(数字、符号、字母)

private string GetNum()
{

Random rd = new Random();
char[] strRandomList = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '!', '@', '#', '$', '%', '&', '*', '_' };
string pwd = "";
for (int i = 0; i < 6; i++)
{
pwd += strRandomList[rd.Next(strRandomList.Length)];//随机取strRandomList 的项值
}
return pwd;
}

posted on 2015-04-03 11:29  win_your_lo  阅读(938)  评论(0编辑  收藏  举报