要获取值类型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