2

the default monetary sign for money is in $ sign, however I would like to somehow change it to a different currency. example like, ₱ or £.

here is my code as of the moment.

private void cash_Leave(object sender, EventArgs e)
{
    double value;
    if(Double.TryParse(cash.Text, out value))
    {
        cash.Text = String.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:C2}", value);
    }
    else
    {
        cash.Text = String.Empty;
    }
}
hensing1
  • 187
  • 13
Mark Suner
  • 23
  • 3
  • Side note: when dealing with currency, it's better to use `decimal`. Doing operations with floating-point numbers (such as `double`) can lead to some nasty rounding errors. – hensing1 Feb 22 '19 at 10:11

2 Answers2

3

The ₱ sign stands for Philippine pesos, so you can just set the CultureInfo to the Philippine culture (en-PH):

String.Format(new System.Globalization.CultureInfo("en-PH"), "{0:C2}", value)

The £ sign stands for British Pounds, so you can use the culture info for Great Britain (en-GB) to get this symbol:

String.Format(new System.Globalization.CultureInfo("en-GB"), "{0:C2}", value)

See here for a list of locale codes.

Sweeper
  • 213,210
  • 22
  • 193
  • 313
0

You have to change Currency Symbol for your Current Culture

i-e do this before your code

var newCulture = System.Globalization.CultureInfo.CurrentCulture.Clone() as CultureInfo;
newCulture.NumberFormat.CurrencySymbol = "₱";
Thread.CurrentThread.CurrentCulture = newCulture;