ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

ToLocalCurrencyString

Convert a double to a string formatted using the local currency settings.

Source

/// <summary>
/// Extensions for numeric types.
/// </summary>
public static class NumericExtensions
{
    /// <summary>
    /// Format a double using the local culture currency settings.
    /// </summary>
    /// <param name="value">The double to be formatted.</param>
    /// <returns>The double formatted based on the local culture currency settings.</returns>
    public static string ToLocalCurrencyString(this double value)
    {
        return (String.Format("{0:C}", value));
    }
}

Example

double test = 145.90;
string testString = test.ToLocalCurrencyString();

Author: Inge Schepers

Submitted on: 11 dec. 2007

Language: C#

Type: System.Double

Views: 5080