重载了一个方法:
public class RepeatDictionaryComparer : IEqualityComparer<string> { public bool Equals(string x, string y) { return x != y; } public int GetHashCode(string obj) { return obj.GetHashCode(); } }
调用:
Dictionary<string, string> _dic = new Dictionary<string, string>(new RepeatDictionaryComparer());
这样重复的键也可以添加了