I need to display data values in US currency format. Meaning 190.8 should display as $190.80. For some reason I cant figure out how to do this. Any advice?
You could explicitly specify the US culture like so:
string.Format(CultureInfo.GetCultureInfo("en-US"), "{0:C}", decimalValue)
The C indicates the default currency format for the specified culture, in this case exactly what you're after. If you want the US currency symbol with a continental European number format (comma instead of period) then your job would be harder of course...
Standard Numeric Format Strings
decimal moneyvalue = 1921.39m;
string html = String.Format("Order Total: {0:C}", moneyvalue);
Console.WriteLine(html);
or
double value = 12345.6789;
Console.WriteLine(value.ToString("C", CultureInfo.CurrentCulture));//CultureInfo.GetCultureInfo("en-US")
// current culture is English (United States):
// $12,345.68
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With