Parse string using "$" as the currency symbol for en-GB and en-us cultures.
using System;
using System.Globalization;
class MainClass
{
public static void Main()
{
string value = "$6,543.21";
NumberStyles style = NumberStyles.Number | NumberStyles.AllowCurrencySymbol;
CultureInfo provider = new CultureInfo("en-GB");
try
{
decimal number = Decimal.Parse(value, style, provider);
Console.WriteLine("'{0}' converted to {1}.", value, number);
}
catch (FormatException)
{
Console.WriteLine("Unable to parse '{0}'.", value);
}
}
}
Related examples in the same category