本文介绍了字符串比较:InvariantCultureIgnoreCase VS OrdinalIgnoreCase?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这将是更好的code:
INT指数= fileName.LastIndexOf(,StringComparison.InvariantCultureIgnoreCase。);
或
INT指数= fileName.LastIndexOf(,StringComparison.OrdinalIgnoreCase。);
解决方案
如果你真的想只匹配点,那么CultureInfo.Ordinal将是最快的,因为没有大小写的区别。
Which would be better code:
int index = fileName.LastIndexOf(".", StringComparison.InvariantCultureIgnoreCase);
or
int index = fileName.LastIndexOf(".", StringComparison.OrdinalIgnoreCase);
解决方案
If you really want to match only the dot, then the CultureInfo.Ordinal would be fastest, as there is no case-difference.
这篇关于字符串比较:InvariantCultureIgnoreCase VS OrdinalIgnoreCase?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!