Int32.Equals() method with example in C#

Int32.Equals() method with example in C#

C# Int32.Equals() strategy: Here, we will find out about the Equals() technique for int (Int32) struct with its portrayal, syntax, and example.

Int32.Equals() Method

This strategy is utilized to think about two integer articles and returns boolean values either obvious or false.


bool int.equals(int objA, int objB);


int objA, int objB – are utilized to speak to two integer articles to be analyzed.

Return value:

bool – it returns “genuine” if the two items are equivalent, else it returns “false”.

Int32.Equals() Method Example in C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)
            int a = 0;
            int b = 0;

            Console.Write("Enter A: ");
            a = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter B: ");
            b = Convert.ToInt32(Console.ReadLine());

            if (int.Equals(a, b) == true)
                Console.WriteLine("Both are equal");
                Console.WriteLine("Both are not equal");


Enter A: 10
Enter B: 15
Both are not equal

Enter A: 10
Enter B: 10
Both are equal

Recent Posts

error: Alert: Content is protected!!