List<T>
is a reference type which does not overload operator==
. Therefore, it uses the default reference equality semantics. You seem to be under the impression that it overrides operator==
to provide value semantics, but it does not. a
will equal b
when a
and b
both refer to the same List<T>
instance.
EDIT: So I looked at the spec myself. It says:
The List class declares two operators, operator == and operator !=, and thus gives new meaning to expressions that apply those operators to List instances. Specifically, the operators define equality of two List instances as comparing each of the contained objects using their Equals methods. The following example uses the == operator to compare two List instances.
Honestly... I have no clue what they're talking about, but this does not appear to be correct. As far as I can tell after running a few tests the List<T>
class uses reference equality. Good question.
EDIT2: Decompiled List<T>
, no operator==
and/or operator!=
overload. The spec appears to be completely incorrect in this case.