Decimal.ToOACurrency(Decimal) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 Decimal 값을 부가된 64비트 정수에 포함된 해당하는 OLE Automation Currency 값으로 변환합니다.
public:
static long ToOACurrency(System::Decimal value);
public static long ToOACurrency(decimal value);
static member ToOACurrency : decimal -> int64
Public Shared Function ToOACurrency (value As Decimal) As Long
매개 변수
- value
- Decimal
변환할 10진수입니다.
반품
OLE Automation에 해당하는 64비트 부가 정수입니다 value.
예제
다음 코드 예제에서는 이 메서드를 사용하여 ToOACurrency 숫자를 필드에 포함된 해당하는 OLE Automation Currency 값으로 Decimal 변환 Int64 합니다.
// Example of the decimal.ToOACurrency method.
using System;
class DecimalToOACurrencyDemo
{
const string dataFmt = "{0,31}{1,27}";
// Get the exception type name; remove the namespace prefix.
public static string GetExceptionType( Exception ex )
{
string exceptionType = ex.GetType( ).ToString( );
return exceptionType.Substring(
exceptionType.LastIndexOf( '.' ) + 1 );
}
// Display the decimal.ToOACurrency parameter and the result
// or exception.
public static void ShowDecimalToOACurrency( decimal Argument )
{
// Catch the exception if ToOACurrency( ) throws one.
try
{
long oaCurrency = decimal.ToOACurrency( Argument );
Console.WriteLine( dataFmt, Argument, oaCurrency );
}
catch( Exception ex )
{
Console.WriteLine( dataFmt, Argument,
GetExceptionType( ex ) );
}
}
public static void Main( )
{
Console.WriteLine( "This example of the " +
"decimal.ToOACurrency( ) method generates \nthe " +
"following output. It displays the argument as a " +
"decimal \nand the OLE Automation Currency value " +
"as a long.\n" );
Console.WriteLine( dataFmt, "Argument",
"OA Currency or Exception" );
Console.WriteLine( dataFmt, "--------",
"------------------------" );
// Convert decimal values to OLE Automation Currency values.
ShowDecimalToOACurrency( 0M );
ShowDecimalToOACurrency( 1M );
ShowDecimalToOACurrency( 1.0000000000000000000000000000M );
ShowDecimalToOACurrency( 100000000000000M );
ShowDecimalToOACurrency( 100000000000000.00000000000000M );
ShowDecimalToOACurrency( 10000000000000000000000000000M );
ShowDecimalToOACurrency( 0.000000000123456789M );
ShowDecimalToOACurrency( 0.123456789M );
ShowDecimalToOACurrency( 123456789M );
ShowDecimalToOACurrency( 123456789000000000M );
ShowDecimalToOACurrency( 4294967295M );
ShowDecimalToOACurrency( 18446744073709551615M );
ShowDecimalToOACurrency( -79.228162514264337593543950335M );
ShowDecimalToOACurrency( -79228162514264.337593543950335M );
}
}
/*
This example of the decimal.ToOACurrency( ) method generates
the following output. It displays the argument as a decimal
and the OLE Automation Currency value as a long.
Argument OA Currency or Exception
-------- ------------------------
0 0
1 10000
1.0000000000000000000000000000 10000
100000000000000 1000000000000000000
100000000000000.00000000000000 1000000000000000000
10000000000000000000000000000 OverflowException
0.000000000123456789 0
0.123456789 1235
123456789 1234567890000
123456789000000000 OverflowException
4294967295 42949672950000
18446744073709551615 OverflowException
-79.228162514264337593543950335 -792282
-79228162514264.337593543950335 -792281625142643376
*/
// Example of the Decimal.ToOACurrency method.
open System
let dataFmt obj1 obj2 = printfn $"{obj1,31}{obj2,27}"
// Get the exception type name; remove the namespace prefix.
let getExceptionType (ex: exn) =
let exceptionType = ex.GetType() |> string
exceptionType.Substring(exceptionType.LastIndexOf '.' + 1)
// Display the Decimal.ToOACurrency parameter and the result
// or exception.
let showDecimalToOACurrency argument =
// Catch the exception if ToOACurrency( ) throws one.
try
let oaCurrency = Decimal.ToOACurrency argument
dataFmt argument oaCurrency
with ex ->
dataFmt argument (getExceptionType ex)
printfn
"""This example of the Decimal.ToOACurrency() method generates
the following output. It displays the argument as a decimal
and the OLE Automation Currency value as a long.
"""
dataFmt "Argument" "OA Currency or Exception"
dataFmt "--------" "------------------------"
// Convert decimal values to OLE Automation Currency values.
showDecimalToOACurrency 0M
showDecimalToOACurrency 1M
showDecimalToOACurrency 1.0000000000000000000000000000M
showDecimalToOACurrency 100000000000000M
showDecimalToOACurrency 100000000000000.00000000000000M
showDecimalToOACurrency 10000000000000000000000000000M
showDecimalToOACurrency 0.000000000123456789M
showDecimalToOACurrency 0.123456789M
showDecimalToOACurrency 123456789M
showDecimalToOACurrency 123456789000000000M
showDecimalToOACurrency 4294967295M
showDecimalToOACurrency 18446744073709551615M
showDecimalToOACurrency -79.228162514264337593543950335M
showDecimalToOACurrency -79228162514264.337593543950335M
// This example of the Decimal.ToOACurrency() method generates
// the following output. It displays the argument as a decimal
// and the OLE Automation Currency value as a long.
//
// Argument OA Currency or Exception
// -------- ------------------------
// 0 0
// 1 10000
// 1.0000000000000000000000000000 10000
// 100000000000000 1000000000000000000
// 100000000000000.00000000000000 1000000000000000000
// 10000000000000000000000000000 OverflowException
// 0.000000000123456789 0
// 0.123456789 1235
// 123456789 1234567890000
// 123456789000000000 OverflowException
// 4294967295 42949672950000
// 18446744073709551615 OverflowException
// -79.228162514264337593543950335 -792282
// -79228162514264.337593543950335 -792281625142643376
' Example of the Decimal.ToOACurrency method.
Module DecimalToOACurrencyDemo
Const dataFmt As String = "{0,31}{1,27}"
' Get the exception type name; remove the namespace prefix.
Function GetExceptionType( ex As Exception ) As String
Dim exceptionType As String = ex.GetType( ).ToString( )
Return exceptionType.Substring( _
exceptionType.LastIndexOf( "."c ) + 1 )
End Function
' Display the Decimal.ToOACurrency parameter and the result
' or exception.
Sub ShowDecimalToOACurrency( Argument As Decimal )
' Catch the exception if ToOACurrency( ) throws one.
Try
Dim oaCurrency As Long = Decimal.ToOACurrency( Argument )
Console.WriteLine( dataFmt, Argument, _
oaCurrency )
Catch ex As Exception
Console.WriteLine( dataFmt, Argument, _
GetExceptionType( ex ) )
End Try
End Sub
Sub Main( )
Console.WriteLine( "This example of the " & _
"Decimal.ToOACurrency( ) method generates " & vbCrLf & _
"the following output. It displays the argument as " & _
"a Decimal " & vbCrLf & "and the OLE Automation " & _
"Currency value as a Long." & vbCrLf )
Console.WriteLine( dataFmt, "Argument", _
"OA Currency or Exception" )
Console.WriteLine( dataFmt, "--------", _
"------------------------" )
' Convert Decimal values to OLE Automation Currency values.
ShowDecimalToOACurrency( 0D )
ShowDecimalToOACurrency( 1D )
ShowDecimalToOACurrency( _
Decimal.Parse( "1.0000000000000000000000000000" ) )
ShowDecimalToOACurrency( 100000000000000D )
ShowDecimalToOACurrency( _
Decimal.Parse( "100000000000000.00000000000000" ) )
ShowDecimalToOACurrency( 10000000000000000000000000000D )
ShowDecimalToOACurrency( 0.000000000123456789D )
ShowDecimalToOACurrency( 0.123456789D )
ShowDecimalToOACurrency( 123456789D )
ShowDecimalToOACurrency( 123456789000000000D )
ShowDecimalToOACurrency( 4294967295D )
ShowDecimalToOACurrency( 18446744073709551615D )
ShowDecimalToOACurrency( -79.228162514264337593543950335D )
ShowDecimalToOACurrency( -79228162514264.337593543950335D )
End Sub
End Module
' This example of the Decimal.ToOACurrency( ) method generates
' the following output. It displays the argument as a Decimal
' and the OLE Automation Currency value as a Long.
'
' Argument OA Currency or Exception
' -------- ------------------------
' 0 0
' 1 10000
' 1.0000000000000000000000000000 10000
' 100000000000000 1000000000000000000
' 100000000000000.00000000000000 1000000000000000000
' 10000000000000000000000000000 OverflowException
' 0.000000000123456789 0
' 0.123456789 1235
' 123456789 1234567890000
' 123456789000000000 OverflowException
' 4294967295 42949672950000
' 18446744073709551615 OverflowException
' -79.228162514264337593543950335 -792282
' -79228162514264.337593543950335 -792281625142643376