Compare this instance is equal to a specified object or Int64 in C#

CsharpServer Side ProgrammingProgramming

To compare this instance is equal to a specified object or Int64, the code is as follows −

Example

 Live Demo

using System;
public class Demo {
   public static void Main() {
      long val1 = 150;
      long val2 = 240;
      Console.WriteLine("Value1 = "+val1);
      Console.WriteLine("Value2 = "+val2);
      Console.WriteLine("Are they equal? = "+val1.Equals(val2));
   }
}

Output

This will produce the following output −

Value1 = 150
Value2 = 240
Are they equal? = False

Example

Let us see another example −

 Live Demo

using System;
public class Demo {
   public static void Main() {
      long val1 = 8768768768;
      long val2 = 8768768768;
      Console.WriteLine("Value1 = "+val1);
      Console.WriteLine("Value2 = "+val2);
      Console.WriteLine("Are they equal? = "+val1.Equals(val2));
   }
}

Output

This will produce the following output −

Value1 = 8768768768
Value2 = 8768768768
Are they equal? = True
raja
Published on 05-Dec-2019 11:31:38
Advertisements