Int32.Equals Method in C# with Examples Last Updated : 04 Apr, 2019 Comments Improve Suggest changes Like Article Like Report Int32.Equals() Method is used to get a value which indicates whether the current instance is equal to a specified object or Int32 or not. There are two methods in the overload list of this method as follows: Equals(Int32) Method Equals(Object) Method Int32.Equals(Int32) This method is used to return a value indicating whether the current instance is equal to a specified Int32 value or not. Syntax: public bool Equals (int obj); Here, it takes a Int32 value to compare to this instance. Return Value: This method returns true if obj has the same value as this instance otherwise, false. Below programs illustrate the use of Int32.Equals(Int32) Method: Example 1: csharp // C# program to demonstrate the // Int32.Equals(Int32) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // Declaring and initializing value1 int value1 = 4562; // Declaring and initializing value2 int value2 = 2563; // using Equals(Int32) method bool status = value1.Equals(value2); // checking the status if (status) Console.WriteLine("{0} is equal to {1}", value1, value2); else Console.WriteLine("{0} is not equal to {1}", value1, value2); } } Output: 4562 is not equal to 2563 Example 2: csharp // C# program to demonstrate the // Int32.Equals(Int32) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // calling get() method get(455, 578); get(445, 445); get(10, 20); get(Int32.MaxValue, Int32.MinValue); } // defining get() method public static void get(int value1, int value2) { // using Equals(Int32) method bool status = value1.Equals(value2); // checking the status if (status) Console.WriteLine("{0} is equal to {1}", value1, value2); else Console.WriteLine("{0} is not equal to {1}", value1, value2); } } Output: 455 is not equal to 578 445 is equal to 445 10 is not equal to 20 2147483647 is not equal to -2147483648 Int32.Equals(Object) Method This method is used to returns a value indicating whether the current instance is equal to a specified object or not. Syntax: public override bool Equals (object obj); Here, it takes an object to compare with this instance. Return Value: This method returns true if obj is an instance of Int32 and equals the value of this instance otherwise, false. Below programs illustrate the use of the above-discussed method: Example 1: csharp // C# program to demonstrate the // Int32.Equals(Object) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // Declaring and initializing value1 int value1 = 10; // Declaring and initializing value2 object value2 = 1 / 45; // using Equals(object) method bool status = value1.Equals(value2); // checking the status if (status) Console.WriteLine("{0} is equal to {1}", value1, value2); else Console.WriteLine("{0} is not equal to {1}", value1, value2); } } Output: 10 is not equal to 0 Example 2: csharp // C# program to demonstrate the // Int32.Equals(Object) Method using System; using System.Globalization; class GFG { // Main Method public static void Main() { // calling get() method get(547, 585); get(555, 489); get(100, 100); get(745, 725); } // defining get() method public static void get(int value1, object value2) { // compare both Int32 value // using Equals(object) method bool status = value1.Equals(value2); // checking the status if (status) Console.WriteLine("{0} is equal to {1}", value1, value2); else Console.WriteLine("{0} is not equal to {1}", value1, value2); } } Output: 547 is not equal to 585 555 is not equal to 489 100 is equal to 100 745 is not equal to 725 Reference: https://docs.microsoft.com/en-us/dotnet/api/system.int32.equals?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article Int32.Equals Method in C# with Examples K Kirti_Mangal Follow Improve Article Tags : C# CSharp-method CSharp-Int32-Struct Similar Reads Int16.Equals Method in C# with Examples Int16.Equals() Method is used to get a value which indicates whether the current instance is equal to a specified object or Int16. There are 2 methods in the overload list of this method which are as follows: Equals(Int16) Method Equals(Object) Method Int16.Equals(Int16) This method is used to retur 4 min read Int64.Equals Method in C# with Examples Int64.Equals() Method is used to get a value that shows whether the current instance is equal to a specified object or Int64. There are 2 methods in the overload list of this method as follows: Equals(Int64) Method Equals(Object) Method Int64.Equals(Int64) This method is used to return a value indic 3 min read SByte.Equals Method in C# with Examples SByte.Equals Method is used to get a value which indicates whether the current instance is equal to a specified object or SByte or not. There are 2 methods in the overload list of this method as follows: Equals(SByte) Method Equals(Object) Method SByte.Equals(SByte) Method This method is used to ret 3 min read Int32.CompareTo Method in C# with Examples Int32.CompareTo Method is used to compare the current instance to a specified object or Int32 and returns a sign of their relative values. There are 2 methods in the overload list of this method as follows: CompareTo(Int32) Method CompareTo(Object) Method Int32.CompareTo(Int32) Method This method is 4 min read Single.Equals() Method in C# with Examples Single.Equals() Method is used to get a value which indicates whether the two instances of Single represents the same value or not. There are 2 methods in the overload list of this method as follows: Equals(Single) Method Equals(Object) Method Single.Equals(Single) Method This method is used to retu 3 min read Like