# Decimal.ToOACurrency() Method in C#

Decimal.ToOACurrency(Decimal) Method is used to convert the specified Decimal value to the equivalent OLE Automation Currency value, which is contained in a 64-bit signed integer.

Syntax: public static long ToOACurrency (decimal value);
Here, it takes the decimal number to convert.

Return Value: This method returns a 64-bit signed integer that contains the OLE Automation equivalent of value.

Below programs illustrate the use of Decimal.ToOACurrency() Method

Example 1:

 `// C# program to demonstrate the ` `// Decimal.ToOACurrency() Method ` `using` `System; ` `using` `System.Globalization; ` ` `  `class` `GFG { ` ` `  `    ``// Main Method ` `    ``public` `static` `void` `Main() ` `    ``{ ` `        ``// Declaring and initializing value1 ` `        ``Decimal curr = 40; ` ` `  `        ``// A 64-bit signed integer that contains ` `        ``// the OLE Automation equivalent of value. ` `        ``long` `value = Decimal.ToOACurrency(curr); ` ` `  `        ``// Display the HashCode ` `        ``Console.WriteLine(``"Equivalent long value is {0}"``, value); ` `    ``} ` `} `

Output:

```Equivalent long value is 400000
```

Example 2:

 `// C# program to demonstrate the ` `// Decimal.ToOACurrency() Method ` `using` `System; ` `using` `System.Globalization; ` ` `  `class` `GFG { ` ` `  `    ``// Main Method ` `    ``public` `static` `void` `Main() ` `    ``{ ` `        ``// calling get() method ` `        ``Console.WriteLine(``"Equivalent long value are respectivily"``); ` `        ``get``(20); ` `        ``get``(30); ` `        ``get``(40); ` `        ``get``(4294967295); ` `    ``} ` ` `  `    ``// defining get() method ` `    ``public` `static` `void` `get``(``decimal` `curr) ` `    ``{ ` ` `  `        ``// getting Equivalent decimal value ` `        ``// using ToOACurrency() method ` `        ``long` `value = Decimal.ToOACurrency(curr); ` ` `  `        ``// Display the HashCode ` `        ``Console.WriteLine(``"{0}"``, value); ` `    ``} ` `} `

Output:

```Equivalent long value are respectivily
200000
300000
400000
42949672950000
```

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.