C implements the method of case switching on strings
- 2021-01-14 06:28:10
- OfStack
This article shows how C# implements case switching for strings. Share with you for your reference. The specific implementation method is as follows:
The C# code is as follows:
public class Program
{
public static void Main()
{
string s = "OsChInAhI § $%&/()1234567890";
Func<char, char> toggle = c => char.IsUpper(c) ? char.ToLower(c) : char.ToUpper(c);
Console.WriteLine(s);
Console.WriteLine(new string(s.Select(toggle).ToArray()));
}
}
I hope this article is helpful to your C# programming.