使用ToUpperInvariant避免使用ToUpper
ToUpperInvariant使用不依赖于区域性进行转换,而ToUpper则使用了当前线程的CultureInfo,进行转换,所以性能会有所影响,以下为测试:
[Test]public void TestInvariant(){Int32 count = 1000 * 1000;Stopwatch watch = new Stopwatch();String str = "abcdefghijklmnopqrstuvwxyz中华人民共和国";watch = Stopwatch.StartNew();for (int i = 0; i < count; i++){str.ToUpperInvariant();}Console.WriteLine("ToUpperInvariant:{0}", watch.Elapsed.ToString());}[Test]public void TestNoInvariant(){Int32 count = 1000 * 1000;Stopwatch watch = new Stopwatch();String str = "abcdefghijklmnopqrstuvwxyz中华人民共和国";watch = Stopwatch.StartNew();for (int i = 0; i < count; i++){str.ToUpper();}Console.WriteLine("ToUpper:{0}", watch.Elapsed.ToString());}
ToUpperInvariant:00:00:00.2980660
ToUpper:00:00:00.3281423
如果 确认当前的比较和区域性无关的话,推荐使用ToUppperInvariant
使用ToUpperInvariant避免使用ToUpper相关推荐
- R语言大小写转换函数(tolower, toupper, casefold,chartr)实战
R语言大小写转换函数(tolower, toupper, casefold,chartr)实战 目录 R语言大小写转换函数(tolower, toupper, casefold,chartr)实战 # ...
- golang中strings.ToUpper
golang中字符串操作strings.ToUpper package mainimport ("fmt""strings")//golang字符串操作 fun ...
- 用tolower()和toupper()来实现对string进行大小写转换
int tolower(int c) 把给定的字母转换为小写字母. 函数原型: int tolower(int c); 参数 c:这是要被转换为小写的字母. 返回值:如果 c 有相对应的小写字母,则该 ...
- 慎用ToLower和ToUpper,小心把你的系统给拖垮了
不知道何时开始,很多程序员喜欢用ToLower,ToUpper去实现忽略大小写模式的字符串相等性比较,有可能这个习惯是从别的语言引进的,大胆猜测下是JS,为了不引起争论,我指的JS是技师的意思~ 一: ...
- c语言toupper_在C中使用toupper()–实用指南
c语言toupper In this article, we'll take a look at how we can use the toupper() function in C. 在本文中,我们 ...
- C语言怎么提出大写字母,c语言函数toupper()如何将小写字母转换为大写字母
c语言函数toupper()如何将小写字母转换为大写字母?大小写字母怎么转换?函数需要引入的头文件:#include toupper()的定义:int toupper(int c); toupper( ...
- toupper() 函数
toupper 语法: #include <ctype.h> int toupper( int ch ); 功能:函数字符ch的大写形式.
- C语言函数:tolower()、toupper字符大小写转换函数。
C语言函数:tolower().toupper字符大小写转换函数. int toupper( int c) int tolower( int c) tolower():将字母转为小写. toupper ...
- C语言函数:toupper
原型:extern int toupper(int c); 用法:#include <ctype.h> 功能:将字符c转换为大写英文字母 说明:如果c为小写英文字母,则返回对应的大写字母: ...
- C语言toupper()函数:将小写字母转换为大写字母
头文件:#include <ctype.h> 定义函数:int toupper(int c); 函数说明:若参数 c 为小写字母则将该对应的大写字母返回. 返回值:返回转换后的大写字母,若 ...
最新文章
- JHipster开发环境安装
- java main函数_一行JAVA代码如何运行起来?
- 百度小程序全套源码下载、免费分享,一键生成百度小程序
- 【Python】政府工作报告词云
- c/c++教程 - 1.7 数组 一维数组 二维数组
- dataframe 绘图——按照每列出一个图(df.plot)
- centos6.5 mysql配置整理
- python画图案 使用循环完成_利用python在终端模拟下雪的效果
- 如何修复uefi引导?这种方法才是最有效的解决方法
- 喜大普奔!ios原生键盘终于支持自然码双拼了!
- 重复抽样与不重复抽样的抽样平均误差大小?
- 压力大对身体有没有伤害,你觉的有伤害就有伤害,你觉的没伤害就没伤害
- TC流量控制HTB示例
- Google Search Console使用教程_谷歌管理员工具用法
- 3年级计算机的知识能力,三年级信息技术教案资料三篇
- 喜大普奔!Maya 2022来了?!
- 视频工厂:如何拍摄优质的餐饮宣传片之品牌植入篇
- 2.4G无线技术参数及行业分享
- atlas mysql 分表,Atlas实现Mysql读写分离
- 电驴提示“该内容尚未提供权利证明,无法提供下载”之解决办法
热门文章
- treefrog之视图 ERB
- 刘邦的用人之道!真心服气
- 传说华为面试爱问正则,这不海外留学生校招面试题来了
- CentOS 用Strongswan搭建IPSec ***
- 2021-04-29【已解决】The server cannot or will not process the request due to something that is perceived
- Only one expression can be specified in the select list when the subquery is not introduced with EXI
- 中国大学MOOC公开信息收集
- php eot,PHP定界符EOT的用法
- 360实习之--技术基础H卷
- 第二届春回燕归 浙籍精英峰会见闻