在 C# 中获取值类型 Char 的 TypeCode
要获取值类型 Char 的 TypeCode,代码如下 −
示例
using System; public class Demo { public static void Main() { char val = '5'; bool res; Console.WriteLine("Hashcode for val = "+val.GetHashCode()); res = val.Equals('m'); Console.WriteLine("Return Value = "+res); Console.WriteLine("Numeric Value = "+Char.GetNumericValue(val)); TypeCode type = val.GetTypeCode(); Console.WriteLine("Type = "+type); } }
输出
将生成以下输出 −
Hashcode for val = 3473461 Return Value = False Numeric Value = 5 Type = Char
示例
让我们看另一个示例 −
using System; public class Demo { public static void Main() { char val = 'B'; TypeCode type = val.GetTypeCode(); Console.WriteLine("Type = "+type); } }
输出
将生成以下输出 −
Type = Char
广告