Custom Class used as key in Dictionary but key not found
I have a class, show below, which is used as a key in a Dictionary<ValuesAandB, string> I'm having issues when trying to find any key within this dictionary, it never finds it at all. As you can see, I have overridden Equals and GetHashCode . To look for the key I'm using ValuesAandB key = new ValuesAandB(A,B); if (DictionaryName.ContainsKey(key)) { ... } Is there anything else that I'm missing? Can anyone point out what I'm doing wrong? private class ValuesAandB { public string valueA; public string valueB; // Constructor public ValuesAandB (string valueAIn, string valueBIn) { valueA =