Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Type.GetTypeCode Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the underlying type code of the specified Type.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public static TypeCode GetTypeCode(
	Type type
)

Parameters

type
Type: System.Type
The Type whose underlying type code to get.

Return Value

Type: System.TypeCode
The TypeCode value of the underlying type.

The following code example demonstrates how the TypeCode enumeration can be used. In a decision block inside the WriteObjectInfo method, the TypeCode of an Object parameter is examined, and an appropriate message is written to the console.


static void WriteObjectInfo(System.Windows.Controls.TextBlock outputBlock, object testObject)
{
   TypeCode typeCode = Type.GetTypeCode(testObject.GetType());

   switch (typeCode)
   {
      case TypeCode.Boolean:
         outputBlock.Text += String.Format("Boolean: {0}", testObject) + "\n";
         break;

      case TypeCode.Double:
         outputBlock.Text += String.Format("Double: {0}", testObject) + "\n";
         break;

      default:
         outputBlock.Text += String.Format("{0}: {1}", typeCode.ToString(), testObject) + "\n";
         break;
   }
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show: