Int64 - FromOACurrency

Converts the specified 64-bit signed integer, which contains an OLE Automation Currency value, to the equivalent value.

Try it

const string dataFmt = "{0,31}{1,27}";

public static void Main()
{
    Int64[] values = { 0, 1, 100000, 123456789, 184467440737095516 };

    Console.WriteLine(dataFmt, "Int64", "FromOACurrency");
    Console.WriteLine(dataFmt, "-----", "--------------");

    foreach (Int64 value in values)
    {
        try
        {
			// C# Extension Method: Decimal - FromOACurrency
            Decimal fromOACurrency = value.FromOACurrency();
            Console.WriteLine(dataFmt, value, fromOACurrency);
        }
        catch (Exception ex)
        {
            Console.WriteLine(dataFmt, value,
                GetExceptionType(ex));
        }
    }
}

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

View Source
using System;

public static partial class Extensions
{
    /// <summary>
    ///     Converts the specified 64-bit signed integer, which contains an OLE Automation Currency value, to the
    ///     equivalent  value.
    /// </summary>
    /// <param name="cy">An OLE Automation Currency value.</param>
    /// <returns>A  that contains the equivalent of .</returns>
    public static Decimal FromOACurrency(this Int64 cy)
    {
        return Decimal.FromOACurrency(cy);
    }
}