使用 string 的一些规则
来源:互联网 发布:sql delete table 编辑:程序博客网 时间:2024/06/05 01:15
使用 string 的一些规则
//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 typeStringComparison.
对字符串操作时使用明确地指定字符串比较规则那些重载函数。
通常,这意味这调用有一个参数类型为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 onCultureInfo.InvariantCulturewhen the comparison is linguistically irrelevant (symbolic, for example).
如果比较是语言学无关的,使用StringComparison.Ordinal or StringComparison.OrdinalIgnoreCase (效率会更高?),而不是CultureInfo.InvariantCulture
· Use the String.ToUpperInvariantmethod instead of the String.ToLowerInvariantmethod when you normalize strings for comparison.
推荐使用String.ToUpperInvariant 而不是String.ToLowerInvariant
//z 2012-2-7 16:50:57 PM IS2120@CSDN
· Use an overload of the String.Equalsmethod to test whether two strings are equal.
使用string.equals的重载方法测试两个string是否一致。
· Use Compareand CompareToto 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 String.Compareor CompareTomethod 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
- 使用 string 的一些规则
- 使用Lapack库的一些重要规则
- git的一些使用规则总结
- String中一些方法的使用
- Java String的一些方法使用
- Java String使用的一些新手坑
- 画用例图的一些规则
- 指针的一些规则
- 一些规则的总结
- python的一些规则
- 一些好的规则
- eslint 的一些规则
- 关于指针赋值和const使用的一些规则
- 使用 XHTML 重构网站的一些规则和概要
- 关于sqlite3使用top的一些规则总结
- 关于sqlite3使用top的一些规则总结
- 关于sqlite3使用top的一些规则总结
- 关于sqlite3使用top的一些规则总结
- CCIE-4.0理论及配置 Secure Shell (SSH)
- 在Eclipse里自动导入相应包的类名的快捷键
- 理想
- 超实用的生活秘方
- 观察者模式
- 使用 string 的一些规则
- According to TLD or attribute directive in tag file, attribute value does not accept any expressions
- 牛顿迭代法求方程的根
- BlackBerry PlayBook NDK 2.0 使用Cocos2dx详细步骤
- getServletContext()空指针异常的原因
- vmware ubuntu10.04出现 sudo: must be setuid root
- 命令模式
- abap bapi badi 有什么区别?
- iOS-在iphone上使用ps命令查看进程