C# 获取含有数字大小写字母的密码
public string GetPassWord() { string text = string.Empty; var number = "0123456789"; var chars = "ABCDEFGHJKLMNOPQRSTUVWXYZabcefghijkmnopqrstuvwxyz"; var random = new Random(); text += new string(Enumerable.Repeat(number, 4).Select(s => s[random.Next(s.Length)]).ToArray()); text += new string(Enumerable.Repeat(chars, 4).Select(s => s[random.Next(s.Length)]).ToArray()); char[] cArr = text.ToCharArray(); string result = ""; for (int i = text.Length - 1; i >= 0; i--) { int index = random.Next(0, i); result += cArr[index]; cArr[index] = cArr[i]; } return result; }