Decimal.GetTypeCode 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
public:
virtual TypeCode GetTypeCode();
public TypeCode GetTypeCode ();
abstract member GetTypeCode : unit -> TypeCode
override this.GetTypeCode : unit -> TypeCode
Public Function GetTypeCode () As TypeCode
傳回
列舉的常數 Decimal。
實作
範例
下列程式碼範例會 GetTypeCode
使用 方法來傳回實值型別的類型代碼 Decimal
。
// Example of the Decimal::GetTypeCode method.
using namespace System;
int 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 = 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
*/
// 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
*/
// Example of the Decimal.GetTypeCode method.
open System
printfn $"This example of the decimal.GetTypeCode() \nmethod generates the following output.\n"
// Create a decimal object and get its type code.
let aDecimal = Decimal 1.0
let typCode = aDecimal.GetTypeCode()
printfn $"Type Code: \"{typCode}\""
printfn $"Numeric value: {int typCode}"
// This example of the decimal.GetTypeCode()
// method generates the following output.
//
// Type Code: "Decimal"
// Numeric value: 15
' Example of the Decimal.GetTypeCode method.
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