This documentation is archived and is not being maintained.

Type.GetTypeCode Method

Gets the underlying type code of the specified Type.

[Visual Basic]
Public Shared Function GetTypeCode( _
   ByVal type As Type _
) As TypeCode
public static TypeCode GetTypeCode(
 Type type
public: static TypeCode GetTypeCode(
 Type* type
public static function GetTypeCode(
   type : Type
) : TypeCode;


The Type whose underlying type code to get.

Return Value

The TypeCode value of the underlying type.


[Visual Basic] 
' Creates an object of 'Type' class.
Dim myType1 As Type = Type.GetType("System.Int32")
' Get the 'TypeCode' of the 'Type' class object created above.
Dim myTypeCode As TypeCode = Type.GetTypeCode(myType1)
Console.WriteLine("TypeCode is: {0}", myTypeCode)

// Create an object of 'Type' class.
Type myType1 = Type.GetType("System.Int32");
// Get the 'TypeCode' of the 'Type' class object created above.
TypeCode myTypeCode = Type.GetTypeCode(myType1);
Console.WriteLine("TypeCode is: {0}",myTypeCode);

// Create an object of 'Type' class.
Type*  myType1 = Type::GetType(S"System.Int32");
// Get the 'TypeCode' of the 'Type' class object created above.
TypeCode myTypeCode = Type::GetTypeCode(myType1);
Console::WriteLine(S"TypeCode is: {0}",__box( myTypeCode));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

Type Class | Type Members | System Namespace | TypeCode