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

 1 private string GetNum()
 2 {
 3 Random rd = new Random();
 4 char[] strRandomList = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 
 5 
 6 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 
 7 
 8 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 
 9 
10 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 
11 
12 'x', 'y', 'z', '!', '@', '#', '$', '%', '&', '*', '_' };
13 
14 string pwd = "";
15 for (int i = 0; i < 6; i++)
16 {
17 pwd += strRandomList[rd.Next(strRandomList.Length)];//随机取strRandomList 的项值
18 }
19 return pwd;
20 }
posted @ 2015-04-15 17:14  Tz__C  阅读(773)  评论(0)    收藏  举报