In the above-linked answer on Stack Overflow, I explained the different kinds of equivalence in programming, and how they are implemented in C#.
To summarize, in programming, there are four kinds of object equivalence:
- Reference Equality, object.ReferenceEquals(a, b): The two variables point to the same exact object in RAM. (If this were C, both variables would have the same exact pointer.)
- Interchangeability, a == b: The two variables refer to objects that are completely interchangeable. Thus, when a == b, Func(a,b) and Func(b,a) do the same thing.
- Semantic Equality, object.Equals(a, b): At this exact moment in time, the two objects mean the same thing.
- Entity equality, a.Id == b.Id: The two objects refer to the same entity, such as a database row, but don’t have to have the same contents.