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.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- type
- Type: System.Type
The Type whose underlying type code to get.
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.
Sub WriteObjectInfo(ByVal outputBlock As System.Windows.Controls.TextBlock, ByVal testObject As Object) Dim typeCode As TypeCode = Type.GetTypeCode(testObject.GetType()) Select Case typeCode Case typeCode.Boolean outputBlock.Text += String.Format("Boolean: {0}", testObject) & vbCrLf Case typeCode.Double outputBlock.Text += String.Format("Double: {0}", testObject) & vbCrLf Case Else outputBlock.Text += String.Format("{0}: {1}", typeCode.ToString(), testObject) & vbCrLf End Select End Sub
Show: