我有清单,我怎样才能获得不同的价值观?
IList<string> words = new List<string> { "A","b","a" }; var distinctWords = words.Distinct(StringComparison.OrdinalIgnoreCase);
这给了我错误:
Distinct有一些无效的参数.
解决方法
您需要:
StringComparer.OrdinalIgnoreCase
而不是StringComparison.OrdinalIgnoreCase
IList<string> words = new List<string> { "A","a" }; var distinctWords = words.Distinct(StringComparer.OrdinalIgnoreCase);