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.
Syntax:
bool int.equals(int objA, int objB);
Parameter(s):
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");
}
else
{
Console.WriteLine("Both are not equal");
}
}
}
}
Output
Enter A: 10
Enter B: 15
Both are not equal
Enter A: 10
Enter B: 10
Both are equal