Byte.Equals(Byte) Method in C#


The Byte.Equals(Byte) method in C# returns a value indicating whether this instance and a specified Byte object represent the same value.

Syntax

Following is the syntax −

public bool Equals (byte ob);

Above, ob is an object to compare to this instance.

Example

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

using System;
public class Demo {
   public static void Main(){
      byte b1, b2;
      b1 = 5;
      b2 = 5;
      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 = b2

Updated on: 11-Nov-2019

252 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements