Decimal.GetTypeCode Method (System)

Switch View :
ScriptFree
.NET Framework Class Library for Silverlight
Decimal.GetTypeCode Method

Returns the TypeCode for value type Decimal.

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

Visual Basic (Declaration)
Public Function GetTypeCode As TypeCode
C#
public TypeCode GetTypeCode()

Return Value

Type: System.TypeCode
The enumerated constant TypeCode.Decimal.

Implements

IConvertible.GetTypeCode()
Examples

The following code example uses the GetTypeCode method to return the type code for Decimal value type.

Visual Basic

' Example of the Decimal.GetTypeCode method. 

Module Example

   Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      outputBlock.Text &= "This example of the " & _
          "Decimal.GetTypeCode( ) " & vbCrLf & "method " & _
          "generates the following output." & vbCrLf & vbCrLf

      ' Create a Decimal object and get its type code.
      Dim aDecimal As Decimal = New Decimal(1.0)
      Dim typCode As TypeCode = aDecimal.GetTypeCode()

      outputBlock.Text &= String.Format("Type Code:      ""{0}""", typCode) & vbCrLf
      outputBlock.Text &= String.Format("Numeric value:  {0}", CInt(typCode)) & vbCrLf
   End Sub
End Module

' This example of the Decimal.GetTypeCode( )
' method generates the following output.
' 
' Type Code:      "Decimal"
' Numeric value:  15


C#

// Example of the decimal.GetTypeCode method. 
using System;

class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      outputBlock.Text += "This example of the " +
          "decimal.GetTypeCode( ) \nmethod " +
          "generates the following output.\n" + "\n";

      // Create a decimal object and get its type code.
      decimal aDecimal = new decimal(1.0);
      TypeCode typCode = aDecimal.GetTypeCode();

      outputBlock.Text += String.Format("Type Code:      \"{0}\"", typCode) + "\n";
      outputBlock.Text += String.Format("Numeric value:  {0}", (int)typCode) + "\n";
   }
}

/*
This example of the decimal.GetTypeCode( )
method generates the following output.

Type Code:      "Decimal"
Numeric value:  15
*/


Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0
Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference