ToSpecificCurrencyString
Convert a double to a string formatted using the culture settings (string representation) passed into the procedure.
Source
/// <summary>
/// Extensions for numeric types.
/// </summary>
public static class NumericExtensions
{
/// <summary>
/// Format a double using specific culture currency settings.
/// </summary>
/// <param name="value">The double to be formatted.</param>
/// <param name="cultureName">The string representation for the culture to be used, for instance "en-US" for US English.</param>
/// <returns>The double formatted based on specific culture currency settings.</returns>
public static string ToSpecificCurrencyString(this double value, string cultureName)
{
CultureInfo currentCulture = new CultureInfo(cultureName);
return (string.Format(currentCulture, "{0:C}", value));
}
}
Example
double test = 120.45;
string testString = test.ToSpecificCurrencyString("en-US");