I have this legacy code where there's often this pattern of a dictionary of string to dictionary of string to some object.

Dictionaryretrieval of an object is then always based on two times TryGetValue

Dictionary dicDealers ...if (dicDealers.TryGetValue(lab, out dealers)) dealers.TryGetValue(dealerNumber, out dealer);Now I was thinking it should be more efficient when the two string keys are combined into a key struct with two string members so the objects get retrieved in one go. So I created a Key struct which overrides GetHashCode and Equals calculating a hash on bots key members.

public struct Key{ private T mKey1; private T mKey2; public Key(T t, T u) { mKey1 = t; mKey2 = u; } public override bool Equals(object obj) { if (obj == null) return false; Key rhs = (Key)obj; return mKey1.Equals(rhs.mKey1) && mKey2.Equals(rhs.mKey2); } public override int GetHashCode() { int hash = 17; hash = ((hash