I want to format currency at global level. For English currency format will display as $XXX,XXX.XX. If French then currency format will display as XXX.XXX,XX$. How would I set currency format using Culture and Globalization In C#?
Below is my C# code where I am setting the date format:
if (Thread.CurrentThread.CurrentCulture.Name.Equals("fr-CA") || Thread.CurrentThread.CurrentCulture.Name.Equals("en-CA"))
{
var currentCulture = Thread.CurrentThread.CurrentCulture;
var culture = (CultureInfo)currentCulture.Clone();
culture.DateTimeFormat.ShortDatePattern = "yyyy/MM/dd";
Thread.CurrentThread.CurrentCulture = culture;
}
Use the NumberFormatInfo
via CultureInfo.NumberFormat
and there are various currency-related properties, including CurrencyDecimalSeparator
and CurrencyPositivePattern
.
It looks like you want a positive pattern of 1 - you'll have to look to work out which negative pattern you want.