Answer the question
In order to leave comments, you need to log in
Am I understanding correctly how Equals, ReferenceEquals and == work?
Private types and possibly arrays:
For reference types, unless overridden:
Equals: compares references, but not properties\fields if they are the same
ReferenceEquals: compares references
==: compares references
Primitive types:
Meaningful:
Equals: compares values considering of type
ReferenceEquals: references are compared
==: values are compared
Reference:
Equals: values are compared taking into account type
ReferenceEquals: references are compared
==: values are compared taking into account type
Answer the question
In order to leave comments, you need to log in
No, not right.
Equals - the Equals method is used, which by default compares references, but it is often overridden.
ReferenceEquals - references are compared
== - an operator is called, which is not defined by default in principle
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question