Boolean.Equals(Boolean) Method in C#


The Boolean.Equals(Boolean) method in C# returns a value indicating whether this instance is equal to a specified Boolean object.

Syntax

Following is the syntax −

public bool Equals (bool ob);

Above, ob is a Boolean value to compare to this instance.

Example

Let us now see an example to implement the Boolean.Equals(Boolean) method −

using System;
public class Demo {
   public static void Main(){
      bool b1 = false;
      bool b2 = true;
      bool res = b1.Equals(b2);
      if (res == true)
         Console.Write("b1 equal to b2");
      else
         Console.Write("b1 not equal to b2");
   }
}

Output

This will produce the following output −

b1 not equal to b2

Updated on: 11-Nov-2019

362 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements