The Type.GetTypeCode() method in C# is used to get the underlying type code of the specified Type.
Syntax
Following is the syntax −
public static TypeCode GetTypeCode (Type type);
Above, the type parameter is the type whose underlying type code to get.
Example
Let us now see an example to implement the Type.GetTypeCode() method −
using System;
public class Demo {
public static void Main(){
Type type1 = typeof(double);
TypeCode type2 = Type.GetTypeCode(type1);
Console.WriteLine("TypeCode = "+type2);
}
}Output
This will produce the following output −
TypeCode = Double
Example
Let us now see another example to implement the Type.GetTypeCode() method −
using System;
public class Demo {
public static void Main(){
Type type1 = typeof(short);
TypeCode type2 = Type.GetTypeCode(type1);
Console.WriteLine("TypeCode = "+type2);
}
}Output
This will produce the following output −
TypeCode = Int16