I am trying to check a Dictionary whether or not a certain Object is contained as a key:
Dictionary<Order, int> occurence = new Dictionary<Order, int>();
if (occurence.ContainsKey(order)) {
occurence[order] += 1;
} else {
occurence.Add(order,1);
}
The Order class consists of a simple Dictionary in which I map the properties to their values:
private Dictionary<String, String> properties = new Dictionary<string, string>();
I implemented the HashCode function for the Order class, since the Dictionary lookup depends on it for comparison:
public override int GetHashCode() {
return properties.GetHashCode();
}
Problem is that no matter what the order is not found in the Dictionary. Any idea how to fix this?