0

Please take a look at the following line of code:

TotalFormatted = totalExpenses.ToString("C3", CultureInfo.CreateSpecificCulture("en-GB"))

I am expecting this to output a number as a formatted string with the pound symbol (£1,500) but instead it is outputting GBP1,500

How can I ensure it outputs the actual symbol instead of GBP?

T.S.
  • 18,195
  • 11
  • 58
  • 78
Musaffar Patel
  • 905
  • 11
  • 26

1 Answers1

-2

I settled for the following which correctly formats the string with the pound symbol:

TotalFormatted = totalExpenses.ToString("\u00A3#,##0.00", CultureInfo.CreateSpecificCulture("en-GB"))
Ryan Wilson
  • 10,223
  • 2
  • 21
  • 40
Musaffar Patel
  • 905
  • 11
  • 26
  • 1
    This way I can do `var ss = "£" + 20.33m.ToString("#.00", CultureInfo.CreateSpecificCulture("en-GB"));` or even `var ss = "£" + 20.33m.ToString("#.00")` – T.S. Dec 23 '22 at 20:40
  • @T.S. Thanks, your way looks cleaner therefore I will use your suggestion – Musaffar Patel Dec 23 '22 at 20:41
  • 2
    Why not simply change the currency symbol of the culture: https://dotnetfiddle.net/WBcLyd – Rand Random Dec 23 '22 at 20:54