C#实现对字符串进行大小写切换的方法
作者:鉴客 时间:2021-07-24 03:30:30
本文实例讲述了C#实现对字符串进行大小写切换的方法。分享给大家供大家参考。具体实现方法如下:
C#代码如下:
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()));
}
}
希望本文所述对大家的C#程序设计有所帮助。
标签:C#,字符串,大小写
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
java final 和instanceof 关键字的区别
2021-11-03 13:52:43
Mybatis分解式查询使用方法
2023-08-16 04:15:06
![](https://img.aspxhome.com/file/2023/5/89645_0s.png)
Java的Socket网络编程基础知识入门教程
2021-11-19 10:10:37
Java中去除字符串中所有空格的几种方法
2023-11-24 04:59:24
Spring AOP AspectJ使用及配置过程解析
2023-09-29 00:17:45
Spring Batch轻量级批处理框架实战
2023-01-08 00:24:23
![](https://img.aspxhome.com/file/2023/0/89500_0s.png)
spring mvc中注解@ModelAttribute的妙用分享
2022-09-15 13:53:25
C#之Expression表达式树实例
2023-02-24 20:54:31
springboot整合微信支付sdk过程解析
2021-12-30 22:47:29
![](https://img.aspxhome.com/file/2023/6/59886_0s.jpg)
java 实现迷宫回溯算法示例详解
2023-12-14 23:52:26
![](https://img.aspxhome.com/file/2023/2/62982_0s.png)
解决springboot启动失败的问题('hibernate.dialect' not set)
2023-11-09 03:21:21
详解获取Spring MVC中所有RequestMapping以及对应方法和参数
2023-12-09 21:29:17
c++回调之利用函数指针示例
2022-07-26 06:59:32
详解C#用new和override来实现抽象类的重写区别
2022-12-02 01:50:51
![](https://img.aspxhome.com/file/2023/1/116641_0s.png)
Android开发中Toast显示消息的方法小结
2023-07-31 20:29:14
Android EditText限制输入字数的方法
2021-11-20 18:39:39
JavaWeb项目部署到服务器详细步骤详解
2023-11-29 11:15:20
![](https://img.aspxhome.com/file/2023/4/58764_0s.png)
C#使用正则表达式
2021-11-16 18:33:57
SpringBoot整合MybatisPlus实现增删改查功能
2022-10-31 05:24:15
![](https://img.aspxhome.com/file/2023/8/65728_0s.png)
Springboot打包为Docker镜像并部署的实现
2023-06-05 23:11:52
![](https://img.aspxhome.com/file/2023/1/84761_0s.jpg)