In C# compare method is not straight forward. To compare two objects by value we can use the following code snippet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static bool CompareValue(object o1, object o2) | |
| { | |
| return o1.GetType() == o2.GetType() && Object.Equals(o1, o2); | |
| } |
This method compare the types of two object and then check their value.

Leave a comment