dictionary.Keys.First().GetHashCode() == dictionary.Keys.First().GetHashCode()
returns true
dictionary.Keys.First() == dictionary.Keys.First()
returns true
What's missing? Why can't the dictionary find this object?
Type of dictionary: Dictionary<ExceptionWrapper<Exception>, List<int>>
.
Here is the implementation of ExceptionWrapper.Equals
and ExceptionWrapper.GetHashCode
:
public override int GetHashCode() {
return (typeof(TException).FullName + exception.Message + exception.StackTrace).GetHashCode();
}
public override bool Equals(object obj) {
return
obj is ExceptionWrapper<TException>
&& (obj as ExceptionWrapper<TException>).GetHashCode() == GetHashCode();
}