其中StringComparer的版本使用 [英] Which Version of StringComparer to use

查看:157
本文介绍了其中StringComparer的版本使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想有一个不区分大小写字符串键控字典,它StringComparer的版本我应该用给了这些约束:




  • 来自用英文写的区域只(无论是美国或英国)

  • 或者C#代码或配置文件在字典中的键
  • 该软件是国际化,并在不同的语言环境中运行



我通常使用StringComparer.InvariantCultureIgnoreCase但不知道这是正确的情况。下面是示例代码:

 词典<串,对象>东西=新词典<串,对象>(StringComparer.InvariantCultureIgnoreCase); 


解决方案

This MSDN文章涵盖了你可能要非常深入了解,包括土耳其,我的问题。



这已经有一段时间,因为我读它,所以我要去再次这样做。看到你在一个小时!


If I want to have a case-insensitive string-keyed dictionary, which version of StringComparer should I use given these constraints:

  • The keys in the dictionary come from either C# code or config files written in english locale only (either US, or UK)
  • The software is internationalized and will run in different locales

I normally use StringComparer.InvariantCultureIgnoreCase but wasn't sure if that is the correct case. Here is example code:

Dictionary< string, object> stuff = new Dictionary< string, object>(StringComparer.InvariantCultureIgnoreCase);

解决方案

This MSDN article covers everything you could possibly want to know in great depth, including the Turkish-I problem.

It's been a while since I read it, so I'm off to do so again. See you in an hour!

这篇关于其中StringComparer的版本使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆