Entry
Does == use the Equals method?
Does != use the Equals method?
Apr 27th, 2002 19:38
Nathan Wallace,
Short answer - no.
Long answer:
Equals() is an overridable method for comparing whether two objects
are equivalent.
The rules for != and == are a little complex:
- if the two objects are value objects (like ints), then == is an
equality test
- if the two objects are strings, then == is a (string value) equality
test
eg. the following code returns true
string one = "test";
string two = "test";
one == two
- for any other kind of object, == is an identity test (ie. the
objects being compared have the same object identifier).
!= is just the negation of ==.