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:
csharp
using System;
using System.Globalization;
class GFG {
public static void Main()
{
Decimal curr = 40;
long value = Decimal.ToOACurrency(curr);
Console.WriteLine("Equivalent long value is {0}", value);
}
}
|
Output:
Equivalent long value is 400000
Example 2:
csharp
using System;
using System.Globalization;
class GFG {
public static void Main()
{
Console.WriteLine("Equivalent long value are respectively");
get (20);
get (30);
get (40);
get (4294967295);
}
public static void get ( decimal curr)
{
long value = Decimal.ToOACurrency(curr);
Console.WriteLine("{0}", value);
}
}
|
Reference:
Last Updated :
09 Sep, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...