The XYZ Equals is a method provided by the C# language that allows comparison of two objects for equality. This method is commonly used when overriding the Equals method in a class to provide custom equality logic.
Here are some code examples of how to use XYZ Equals in C#:
// Example 1: Comparing two numbers int num1 = 3; int num2 = 3; bool isEqual = num1.Equals(num2); // returns true
// Example 3: Comparing two custom objects public class Person { public string Name { get; set; } public int Age { get; set; }
public override bool Equals(object obj) { if (obj == null || !(obj is Person)) return false;
Person other = (Person)obj; return this.Name.Equals(other.Name) && this.Age.Equals(other.Age); } }
Person person1 = new Person { Name = "John", Age = 30 }; Person person2 = new Person { Name = "John", Age = 30 }; bool isEqual = person1.Equals(person2); // returns true
The XYZ Equals method is provided in the System.Object class in the .NET framework. Therefore, it is included in the mscorlib.dll library.
C# (CSharp) XYZ.Equals - 30 examples found. These are the top rated real world C# (CSharp) examples of XYZ.Equals extracted from open source projects. You can rate examples to help us improve the quality of examples.