我们在C#中有任何适当的功能吗?
private void button1_Click(object sender, EventArgs e)
{
string s1 = textBox1.Text;
}
答案 0 :(得分:7)
string s1 = new string(
textBox1.Text.Select(ch => char.IsLetter(ch) ? (char.IsUpper(ch) ?
char.ToLower(ch) : char.ToUpper(ch)) : ch).ToArray());
答案 1 :(得分:1)
public string RevString()
{
var s = "TestThisString";
StringBuilder sb = new StringBuilder();
var arr = s.ToCharArray();
foreach (var c in arr)
{
if (c.ToString() == c.ToString().ToLower())
{ sb.Append(c.ToString().ToUpper());}
else
{ sb.Append(c.ToString().ToLower()); }
}
return sb.ToString();
}