Byte.Equals(Object) Method in C#


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

Syntax

Following is the syntax −

public override bool Equals (object ob);

Above, ob is an object to compare with this instance or null.

Example

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

using System;
public class Demo {
   public static void Main(){
      byte b1;
      b1 = 5;
      object b2 = 5/10;
      if (b1.Equals(b2))
         Console.Write("b1 = b2");
      else
         Console.Write("b1 is not equal to b2");
   }
}

Output

This will produce the following output −

b1 is not equal to b2
raja
Published on 08-Nov-2019 10:49:07
Advertisements