Home » C#.Net

Int32.Equals() method with example in C#

C# Int32.Equals() method: Here, we are going to learn about the Equals() method of int (Int32) struct with its description, syntax, and example.
Submitted by IncludeHelp, on October 02, 2019

Int32.Equals() Method

This method is used to compare two integer objects and returns boolean values either true or false.

Syntax:

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

Parameter(s):

  • int objA, int objB – are used to represent two integer objects to be compared.

Return value:

bool – it returns "true" if both objects are equal, 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






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.