dictionary.Keys.First().GetHashCode() == dictionary.Keys.First().GetHashCode()
返回真
dictionary.Keys.First() == dictionary.Keys.First()
返回真
少了什么东西?为什么字典找不到这个对象?
字典类型:Dictionary<ExceptionWrapper<Exception>, List<int>>
.
下面是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();
}