我一直在努力使用 .ToUpper 和 .ToLower 将字符串中的单词转换为相反的大小写。
示例 1:
Input: hello WORLD
Output: HELLO world
示例 2:
Input: THIS is A TEST
Output: this IS a test
最佳答案
C#
string a = "hello WORLD";
string b = new string(a.Select(_ => char.IsLower(_) ? char.ToUpper(_) : char.ToLower(_)).ToArray());
关于c# - 使字符串中的小写大写和大写小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69738834/