使用哪个版本的 StringComparer [英] Which Version of StringComparer to use

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

问题描述

如果我想要一个不区分大小写的字符串键字典,考虑到这些约束,我应该使用哪个版本的 StringComparer:

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

  • 字典中的键来自 C# 代码或仅以英语语言环境(美国或英国)编写的配置文件
  • 该软件已国际化,可在不同的语言环境中运行

我通常使用 StringComparer.InvariantCultureIgnoreCase 但不确定这是否正确.这是示例代码:

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);

推荐答案

这篇 MSDN 文章涵盖了您可能想深入了解的所有内容,包括土耳其语-I 问题.

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天全站免登陆