Educative Answers - Trusted Answers to Developer Questions (2024)

// use System

using System;

// create class

class EqualityChecker

{

// main method

static void Main()

{

// create some values

string name = "Johnny";

string platform = "Edpresso";

bool isGreat = true;

bool isHard = false;

bool isCSharp = true;

int num1 = 3 + 4; // = 7

int num2 = 5 + 6; // = 13

// compare them using

// the `Equals()` method

PrintEquals((string)name, (string)platform);

PrintEquals(name, name);

PrintEquals(isGreat, isHard);

PrintEquals(isGreat, isCSharp);

PrintEquals(num1, num2);

PrintEquals(num1, num1);

}

// check string objects method

static void PrintEquals(object obj1, object obj2){

if(obj1.Equals(obj2)){

Console.WriteLine("Both of the values are equal");

}else{

Console.WriteLine("Both of the values are not equal");

}

}

}

Educative Answers - Trusted Answers to Developer Questions (2024)
Top Articles
Latest Posts
Article information

Author: Dong Thiel

Last Updated:

Views: 6377

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Dong Thiel

Birthday: 2001-07-14

Address: 2865 Kasha Unions, West Corrinne, AK 05708-1071

Phone: +3512198379449

Job: Design Planner

Hobby: Graffiti, Foreign language learning, Gambling, Metalworking, Rowing, Sculling, Sewing

Introduction: My name is Dong Thiel, I am a brainy, happy, tasty, lively, splendid, talented, cooperative person who loves writing and wants to share my knowledge and understanding with you.