.NET Objects Tip - Object Identity vs. Object Equality - Virtual Method Equals in System.Object
- 0
- Add a Comment
From what I have been told, understanding the basics of .NET objects has to be one of the biggest challenges to consider when looking at two different descriptions for .NET objects.
Here is an interesting description of the differences between Object Identity and Object Equality pertaining to objects in the .NET Framework.
Generally speaking, two objects are identical if they share the same address in memory. This means that they are both referring to the same instance of a class. You can test if two objects are identical by using the ReferenceEquals static method of System.Object: Object.ReferenceEquals(myFirstObject, mySecondObject).
On the other hand, two objects are equivalent if they are instances of the same type and if every field of the first object matches the value of the same field of the second object…. Source: davidhayden.com/blog
Tags: object identity, object equality, virtual method, object matches
