string name="abcdef456";
我想让这个字符串随机大小写,456就不用转换了;
就是我每次取name的时候得到的字符串是这种形式的
AbcDef456、AbCDEf456
求大神贴代码
------解决思路----------------------
Random rnd = new Random();
for (int i = 0; i < 10; ++i)
{
string name = "abcdef456";
StringBuilder sb = new StringBuilder();
foreach (var ch in name)
sb.Append(char.IsLetter(ch) ? (rnd.Next(2) == 0 ? char.ToLower(ch) : char.ToUpper(ch)) : ch);
name = sb.ToString();
Console.WriteLine(name);
}