Change Current Thread’s Currency Symbol

Consider the following code. It shows how a decimal value is converted into a string that contains an amount and a currency symbol.

var value = 1099.99m;
Console.WriteLine("{0:C}", value);

// Output: 1,099.99 $

What if we wanted to output a different currency symbol (e.g. “USD”, “€” or “Darsek”) but keep the current number formatting and culture info? If you try the following code, you will probably get an InvalidOperationException stating that the “Instance is read-only“.

Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencySymbol = "Darsek";

This happens because usually the current thread’s culture info is set to a read-only instance that cannot be modified. You will need to create a new instance of CultureInfo. Thankfully, there is a method called “Clone” that we can use to create a new CultureInfo instance with the same properties as the current culture.

var culture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();
culture.NumberFormat.CurrencySymbol = "Darsek";
Thread.CurrentThread.CurrentCulture = culture;

var value = 1099.99m;
Console.WriteLine("{0:C}", value);

// Output: 1,099.99 Darsek

Freelance full-stack .NET and JS developer and architect. Located near Cologne, Germany.

Leave a Reply

Your email address will not be published. Required fields are marked *