Which Version of StringComparer to use(使用哪个版本的 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用哪个版本的 StringComparer
基础教程推荐
- WPF 模态进度窗口 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
