I want to use a custom generic class as a key in a dictionary. How should I override Equals
and GetHashCode
?
Eg,
public class SomeKey<T,V>
{
public T Value1 { get; set; }
public V Value2 { get; set; }
public SomeKey(T val1, V val2)
{
this.Value1 = val1;
this.Value2 = val2;
}
public override bool Equals(SomeKey<T,V> otherKey)
{
//whats the best option here?
}
public override int GetHashCode()
{
//whats the best option here?
}
}
Thanks