本文介绍了在不区分大小写的模式下如何使用HashSet< string> .Contains()方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在不区分大小写的模式下如何使用 HashSet< string> .Contains()方法?
How to use HashSet<string>.Contains() method in case -insensitive mode?
推荐答案您可以使用自定义比较器创建 HashSet :
You can create the HashSet with a custom comparer:
HashSet<string> hs = new HashSet<string>(StringComparer.OrdinalIgnoreCase); hs.Add("Hello"); Console.WriteLine(hs.Contains("HeLLo"));更多推荐
在不区分大小写的模式下如何使用HashSet< string> .Contains()方法?
发布评论