要返回一个指示此实例是否等于指定对象或UInt64的值,代码如下-
using System; public class Demo { public static void Main() { ulong val1 = 44565777; ulong val2 = 77878787; bool res = val1.Equals(val2); Console.WriteLine("Return value (comparison) = "+res); if (res) Console.WriteLine("val1 = val2"); else Console.WriteLine("val1 != val2"); } }
输出结果
这将产生以下输出-
Return value (comparison) = False val1 != val2
让我们看另一个例子-
using System; public class Demo { public static void Main() { ulong val1 = 78796878; ulong val2 = 78796878; bool res = val1.Equals(val2); Console.WriteLine("Return value (comparison) = "+res); if (res) Console.WriteLine("val1 = val2"); else Console.WriteLine("val1 != val2"); } }
输出结果
这将产生以下输出-
Return value (comparison) = True val1 = val2