How do i add a currency symbol before a number?

c#, currency, string

Solution

You can clone the current culture and modify the currency symbol to whatever you want:

var culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
culture.NumberFormat.CurrencySymbol = "!"; // or "¥", etc.

var amount = 1000D;
Console.WriteLine(amount.ToString("C", culture));

This outputs "!1,000.00".

Simply specifying a different culture as the other answers suggest will format the number unexpectedly for the user. For example:

var amount = 1000D;
Console.WriteLine(amount.ToString("C", CultureInfo.CreateSpecificCulture("ru")));
Console.WriteLine(amount.ToString("C", CultureInfo.CreateSpecificCulture("id")));

This outputs:

1 000,00 р.
Rp1.000

Note that the thousands and decimal separators are very different to what I am expecting using the "en-US" culture!

Problem

ToString("C") adds $ symbol before a string. But how do I add other currency types such as Yen, Russian Ruble, Indian Rupee, Swiss Frank? thanks

Original source