Export (0) Print
Expand All

Decimal.GetTypeCode Method

Returns the TypeCode for value type Decimal.

[Visual Basic]
Public Overridable Function GetTypeCode() As TypeCode
[C#]
public virtual TypeCode GetTypeCode();
[C++]
public: virtual TypeCode GetTypeCode();
[JScript]
public function GetTypeCode() : TypeCode;

Return Value

The enumerated constant TypeCode.Decimal.

Example

[Visual Basic, C#, C++] 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. 
Imports System
Imports Microsoft.VisualBasic

Module DecimalGetTypeCodeDemo
    
    Sub Main( )
        Console.WriteLine( "This example of the " & _
            "Decimal.GetTypeCode( ) " & vbCrLf & "method " & _
            "generates the following output." & vbCrLf )

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

        Console.WriteLine( "Type Code:      ""{0}""", typCode )
        Console.WriteLine( "Numeric value:  {0}", CInt( typCode ) )
    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 DecimalGetTypeCodeDemo
{
    public static void Main( )
    {
        Console.WriteLine( "This example of the " +
            "decimal.GetTypeCode( ) \nmethod " +
            "generates the following output.\n" );

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

        Console.WriteLine( "Type Code:      \"{0}\"", typCode );
        Console.WriteLine( "Numeric value:  {0}", (int)typCode );
    }
}

/*
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 <mscorlib.dll>
using namespace System;

void main( )
{
    Console::WriteLine( S"This example of the " 
        S"Decimal::GetTypeCode( ) \nmethod " 
        S"generates the following output.\n" );

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

    Console::WriteLine( S"Type Code:      \"{0}\"", __box( typCode ) );
    Console::WriteLine( S"Numeric value:  {0}", __box( (int)typCode ) );
}

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

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

[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.

Requirements

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

Decimal Structure | Decimal Members | System Namespace

Show:
© 2014 Microsoft