Decimal.FromOACurrency() Method in C#

Decimal.FromOACurrency() Method is used to convert the specified 64-bit signed integer that contains an OLE Automation Currency value, to the equivalent Decimal value.

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

Return Value: This method returns a Decimal that contains the equivalent of cy.



Below programs illustrate the use of Decimal.FromOACurrency(Int64) Method:

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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);
    }
}

chevron_right


Output:

Equivalent decimal value is 922337203685477.5807

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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);
    }
}

chevron_right


Output:

Equivalent decimal value are respectively
922337203685477.5807
-922337203685477.5808
123456789098765.4321
429496.7295

Reference:



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.