This is my code:
public class MyKeyType
{
public int x;
public string operationStr;
}
private static Dictionary<MyKeyType, List<int>> m_Dict = new Dictionary<MyKeyType, List<int>>
{
{ new MyKeyType { x = MyValsType.File, operationStr = "LINK" }, new List<int> { 1,2,3,4,5 } },
{ new MyKeyType { x = MyValsType.File, operationStr = "COPY" }, new List<int> { 10,20,30,40,50 } },
.....
}
List<int> GetValList( int i, string op)
{
// The following line causes error:
return ( m_Dict [ new MyKeyType { x = i, operationStr = op } ] );
}
But I get the error "The given key was not present in the dictionary" when I call:
GetValList( MyValsType.File, "LINK");
Can you tell why? Many thanks in advance.