比较此实例是否等于C#中的指定对象或Int64
要比较此实例是否等于指定的对象或Int64,代码如下-
示例
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)); } }
输出结果
这将产生以下输出-
Value1 = 150 Value2 = 240 Are they equal? = False
示例
让我们看另一个例子-
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)); } }
输出结果
这将产生以下输出-
Value1 = 8768768768 Value2 = 8768768768 Are they equal? = True