博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用 string 的一些规则
阅读量:4703 次
发布时间:2019-06-10

本文共 2133 字,大约阅读时间需要 7 分钟。

//z 2012-2-7 16:50:57 PM IS2120@CSDN
·        Use overloads that explicitly specify the stringcomparison rules for string operations. Typically, this involves calling amethod overload that has a parameter of type.
对字符串操作时使用明确地指定字符串比较规则那些重载函数。
通常,这意味这调用有一个参数类型为StringComparison的重载函数。

·        Use StringComparison.Ordinalor StringComparison.OrdinalIgnoreCase forcomparisons as your safe default for culture-agnostic string matching.

通过StringComparison明确指明是否区分大小(而不是使用默认的,默认的规则在各个类里可能并不一致)

·        Use comparisons with StringComparison.Ordinalor StringComparison.OrdinalIgnoreCase forbetter performance.

·        Use string operations that are based on StringComparison.CurrentCulture when you displayoutput to the user.

如果相应的字符串会显示给用户,那么使用基于StringComparison.CurrentCulture的字符串操作
//z 2012-2-7 16:50:57 PM IS2120@CSDN

·        Use the non-linguistic StringComparison.Ordinal or StringComparison.OrdinalIgnoreCase values insteadof string operations based onwhen the comparison is linguistically irrelevant (symbolic, for example).

如果比较是语言学无关的,使用StringComparison.Ordinal or StringComparison.OrdinalIgnoreCase (效率会更高?),而不是

·        Use the method instead of the method when you normalize strings for comparison.

推荐使用 而不是

·        Use an overload of the method to test whether two strings are equal.

使用string.equals的重载方法测试两个string是否一致。

·        Use and to sort strings, not to check for equality.

将Compare和CompareTo用于对字符串进行排序,而非用于一致性检查

Avoid the following practices when you use strings:

·        Do not use overloads that do not explicitly orimplicitly specify the string comparison rules for string operations.

不要使用那些没有或明或暗指定比较规则的字符串操作函数

·        Do not use string operations based on StringComparison.InvariantCulture in most cases.One of the few exceptions is when you are persisting linguistically meaningfulbut culturally agnostic data.

//z 2012-2-7 16:50:57 PM IS2120@CSDN
在大多数时候都不要使用基于StringComparison.InvariantCulture的函数。

·        Do not use an overload of the or method and test for a return value of zero to determine whether two strings areequal.

不得使用String.Compare或是CompareTo通过测试返回值是否为0来判断两个字符串是否相等。

//z 2012-2-7 16:50:57 PM IS2120@CSDN

转载于:https://www.cnblogs.com/IS2120/archive/2012/02/07/6745948.html

你可能感兴趣的文章
一种链表的实现
查看>>
vue中ESlint报错
查看>>
NetCore2.0 RozarPage自动生成增删改查
查看>>
在商城系统中使用设计模式----策略模式
查看>>
0816 1459 json & pickle ,目录导入,目录规范
查看>>
Alpha 冲刺 (10/10)
查看>>
哈希取余法、哈希表大小取质数的问题
查看>>
asp.net mvc 3.0 远程验证步骤
查看>>
DAL BLL 模板(事务操作)(事务操作中再执行事务操作)
查看>>
内存检测
查看>>
Egret的一些性能优化
查看>>
express中间件的理解
查看>>
Java小案例——对字符串进行加密解密
查看>>
JavaScript规范
查看>>
java Map及Map.Entry详解
查看>>
Docker 启动报错 Error starting daemon: SELinux is not supported with the overlay2 ...alse)
查看>>
基于Spring4+SpringMVC4+Mybatis3+Hibernate4+Junit4框架构建高性能企业级的部标1077视频监控平台...
查看>>
对于两个初始时设置为Sensor的刚体,不会触发preSolve和postSolve
查看>>
将图片url转换为base64与file对象
查看>>
SecureCRT常见配置
查看>>