表明此实例是否等于 C# 中指定的对象或 UInt16
要表明此实例是否等于指定的对象或 UInt16,代码如下 −
示例
using System; public class Demo { public static void Main(){ ushort val1 = 52; ushort val2 = 10; 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(){ ushort val1 = 100; ushort val2 = 100; 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
广告