當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


C# Decimal.FromOACurrency()用法及代碼示例


Decimal.FromOACurrency()方法用於將包含OLE自動化貨幣值的指定64位帶符號整數轉換為等效的Decimal值。

用法: public static decimal FromOACurrency (long cy);
Here, it takes an OLE Automation Currency value.

返回值:此方法返回一個包含cy等效項的Decimal。


以下示例程序旨在說明Decimal.FromOACurrency(Int64)方法的用法:

示例1:

// C# program to demonstrate the 
// Decimal.FromOACurrency() Method 
using System; 
  
class GFG { 
  
    // Main Method 
    public static void Main() 
    { 
  
        // Declaring and initializing value1 
        long curr = long.MaxValue; 
  
        // getting Equivalent decimal value 
        // using IsFinite() method 
        decimal value = Decimal.FromOACurrency(curr); 
  
        // Display the HashCode 
        Console.WriteLine("Equivalent decimal "+ 
                        "value is {0}", value); 
    } 
}
輸出:
Equivalent decimal value is 922337203685477.5807

示例2:

// C# program to demonstrate the 
// Decimal.FromOACurrency() Method 
using System; 
  
class GFG { 
  
    // Main Method 
    public static void Main() 
    { 
  
        // calling get() method 
        Console.WriteLine("Equivalent decimal value"+ 
                                " are respectively"); 
        get(long.MaxValue); 
        get(long.MinValue); 
        get(1234567890987654321); 
        get(4294967295L); 
    } 
  
    // defining get() method 
    public static void get(long curr) 
    { 
  
        // getting Equivalent decimal value 
        // using FromOACurrency() method 
        decimal value = Decimal.FromOACurrency(curr); 
  
        // Display the HashCode 
        Console.WriteLine("{0}", value); 
    } 
}
輸出:
Equivalent decimal value are respectively
922337203685477.5807
-922337203685477.5808
123456789098765.4321
429496.7295

參考:



相關用法


注:本文由純淨天空篩選整理自RohitPrasad3大神的英文原創作品 Decimal.FromOACurrency() Method in C#。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。