找到 2628 篇文章 关于 C#
104 浏览量
要获取当前 UInt64 实例的 HashCode,代码如下:示例 在线演示using System; public class Demo { public static void Main() { ulong val1 = 8768768; ulong val2 = UInt64.MinValue; Console.WriteLine("HashCode for val1 = "+val1.GetHashCode()); Console.WriteLine("HashCode for val2 = "+val2.GetHashCode()); } }输出这将产生以下输出:HashCode for val1 = 8768768 HashCode for val2 = 0示例让我们看另一个示例: 在线演示using System; public class Demo { public static void Main() { ulong val1 = 89879878; ... 阅读更多
67 浏览量
要返回一个值,指示此实例是否等于指定的 object 或 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 ... 阅读更多
90 浏览量
要获取值类型 Int32 的 TypeCode,代码如下:示例 在线演示using System; public class Demo { public static void Main() { int val1 = 100; int val2 = 50; Console.WriteLine("Value1 = "+val1); Console.WriteLine("Value2 = "+val2); Console.WriteLine("Are they equal? = "+val1.Equals(val2)); Console.WriteLine("HashCode for Value1 = "+val1.GetHashCode()); Console.WriteLine("HashCode for Value2 = "+val2.GetHashCode()); TypeCode type1 = val1.GetTypeCode(); TypeCode type2 = val2.GetTypeCode(); Console.WriteLine("TypeCode for Value1 = "+type1); ... 阅读更多
501 浏览量
要将指定 Decimal 的值转换为等效的 64 位无符号整数,代码如下:示例 在线演示using System; public class Demo { public static void Main() { Decimal val = 99.29m; Console.WriteLine("Decimal value = "+val); ulong res = Decimal.ToUInt64(val); Console.WriteLine("64-bit unsigned integer = "+res); } }输出这将产生以下输出:Decimal value = 99.29 64-bit unsigned integer = 99示例让我们看另一个示例: 在线演示using System; public class Demo { public static void Main(){ Decimal val = 0.001m; Console.WriteLine("Decimal value = ... 阅读更多
54 浏览量
要指示此实例是否等于指定的 object 或 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示例让我们现在 ... 阅读更多
367 浏览量
要将指定 Decimal 的值转换为等效的 32 位无符号整数,代码如下:示例 在线演示using System; public class Demo { public static void Main() { Decimal val = 0.001m; Console.WriteLine("Decimal value = "+val); uint res = Decimal.ToUInt32(val); Console.WriteLine("32-bit unsigned integer = "+res); } }输出这将产生以下输出:Decimal value = 0.001 32-bit unsigned integer = 0示例让我们看另一个示例: 在线演示using System; public class Demo { public static void Main() { Decimal val ... 阅读更多
474 浏览量
要获取 Dictionary 中键/值对的数量,代码如下:示例 在线演示using System; using System.Collections.Generic; public class Demo { public static void Main(){ Dictionary
397 浏览量
要将指定的 64 位有符号整数重新解释为双精度浮点数,代码如下:示例 在线演示using System; public class Demo { public static void Main() { long d = 9846587687; Console.Write("Value (64-bit signed integer) = "+d); double res = BitConverter.Int64BitsToDouble(d); Console.Write("Value (double-precision floating point number) = "+res); } }输出这将产生以下输出:Value (64-bit signed integer) = 9846587687 Value (double-precision floating point number) = 4.86486070491012E-314示例让我们看另一个示例: 在线演示using System; public class Demo { public static void Main() { long d = 20; ... 阅读更多
291 浏览量
要将指定字符串的值转换为其等效的 Unicode 字符,代码如下 -示例 实时演示使用 System;public class Demo { public static void Main(){ bool res; char ch; res = Char.TryParse("10", out ch); Console.WriteLine(res); Console.WriteLine(ch.ToString()); } }输出这将产生以下输出 -False示例让我们再看一个示例 - 实时演示使用 System;public class Demo { public static void Main(){ bool res; char ch; res = Char.TryParse("P", out ch); Console.WriteLine(res); Console.WriteLine(ch.ToString()); } }输出这将产生以下输出 -True P