UInt16.GetTypeCode() 方法在 C# 中的示例
C# 中的 UInt16.GetTypeCode() 方法用于返回 UInt16 值类型的 TypeCode。
语法
以下是语法 −
public TypeCode GetTypeCode ();
示例
现在,我们用一个示例来实现 UInt16.GetTypeCode() 方法 −
using System; public class Demo { public static void Main(){ ushort val1 = 55; ushort val2 = 100; TypeCode type1 = val1.GetTypeCode(); TypeCode type2 = val2.GetTypeCode(); Console.WriteLine("Typecode for val1 = "+type1); Console.WriteLine("Typecode for val1 = "+type2); } }
输出
将生成以下输出 −
Typecode for val1 = UInt16 Typecode for val1 = UInt16
示例
现在,我们再用一个示例来实现 UInt16.GetTypeCode() 方法 −
using System; public class Demo { public static void Main(){ ushort val1 = UInt16.MinValue; ushort val2 = 0; TypeCode type1 = val1.GetTypeCode(); TypeCode type2 = val2.GetTypeCode(); Console.WriteLine("Typecode for val1 = "+type1); Console.WriteLine("Typecode for val2 = "+type2); } }
输出
将生成以下输出 −
Typecode for val1 = UInt16 Typecode for val2 = UInt16
广告