string input = Console.ReadLine(); // 读取用户输入的字符串 string output = ""; // 初始化输出字符串 foreach(char c in input) // 遍历输入字符串的每一个字符 { if (char.IsLower(c)) // 如果是小写字母 { output += char.ToUpper(c); // 转换为大写字母并添加到输出字符串中 } else if (char.IsUpper(c)) // 如果是大写字母 { output += char.ToLower(c); // 转换为小写字母并添加到输出字符串中 } else // 如果不是字母 { output += c; // 直接添加到输出字符串中 } } Console.WriteLine(output); // 打印输出字符串

写一给c#语句可以在控制台输入一段英文并大小互换的打印出来

原文地址: https://www.cveoy.top/t/topic/fJ7o 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录