在 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
广告