To be more precise, I have something like this:
Dictionary<KeyValuePair<MyState, MyAction>, float> Dict =
new Dictionary<KeyValuePair<MyState, MyAction>, float>();
Later on, I have a self defined KeyValuePair object;
KeyValuePair<MyState, MyAction> kvp =
new KeyValuePair<MyState, MyAction>(new MyState(...), new MyAction(...));
My question is: if the kvp state and actions have the exactly same values with a pair in Dict (in Dict exists a KeyValuePair with an identical MyState with the kvp MyAction and also, the MyAction from Dict has the exactly same values with the MyAction in kvp). The only difference are that the reference is different.
Long story short, having 2 KeyValuePairs objects, both with the same value (different reference), how can I get the float Value from Dict, without having to iterate the whole dictionary just to manually compare each key.key and key.value just to see if the key is actually the same:
foreach(var StAct in Dict)
if(StAct.Key.Key.Equals(kvp.Key) &&
StAct.Key.Value.Equals(kvp.value))
//where StAct.Key.Key is the MyState object and StAct.Key.Value is the MyAction object
{
MessageBox.Show(StAct.Value + "");
break;
}