Saved Bookmarks
| 1. |
Difference between the Equality Operator (==) and Equals() Method in C#? |
|
Answer» Although both are used to compare two OBJECTS by value, still they both are used differently. For ex.: int x = 10;int y = 10;Console.WriteLine( x == y);Console.WriteLine(x.Equals(y));OUTPUT:TrueTrueEquality operator (==) is a reference type which means that if equality operator is used, it will return TRUE only if both the references point to the same object. |
|