Tag: containskey

字典使用是自定义键,但键始终不相等

我在字典中使用RTBTextPointer作为自定义键… Init.SpintaxEditorPropertyMain.SpintaxListDict = new Dictionary(new RTBTextPointerComparer()); 我在类库中编写RTBTextPointer和RTBTextPointerComparer类,并在不同的wpf项目中使用它, if (Init.SpintaxEditorPropertyMain.SpintaxListDict.ContainsKey(_index) == false) { Init.SpintaxEditorPropertyMain.SpintaxListDict.Add(_index,_SpintaxMappedVal); } everytime containsKey返回false,即使它包含,所以在字典中出现重复条目​​..我的“GetHashCode()”中有任何错误 public class RTBTextPointer { static int _row; static int _column; public int Row { get { return _row; } set { _row = value; } } public int Column { get { return _column; } set { _column = […]

C#列为字典键

我有一个由List键入的字典: private Dictionary<List, string> Lookup; 我正在尝试使用ContainsKey,但它似乎没有工作,我不知道为什么。 以下是我的Visual Studio立即窗口的调试信息: ?Lookup.Keys.ElementAt(7)[0] {custom_obj} Direction: Down SID: 2540 ?Lookup.Keys.ElementAt(7)[1] {custom_obj} Direction: Down SID: 2550 searchObject[0] {custom_obj} Direction: Down SID: 2540 searchObject[1] {custom_obj} Direction: Down SID: 2550 ?Lookup.ContainsKey(searchObject) false 在我的常识中,最后一个ContainsKey应该是真的。 希望我在这里包含了足够的信息……任何想法? 谢谢!