I can\'t understand, why the if
statement in the picture below returns false.
I hope you can explain it to me.
You can see, that the values and the typs
The problem is that the two object wrappers of int
that you are comparing are different objects.
Since object
does not override ==
with a call of Equals
, the comparison checks references instead, and returns false
, because the two objects are different.
You can use object.Equals(item, value)
to avoid this problem.