2

I am using the following code to return my itemValue as currency.

Return String.Format("{0:C}", itemValue)

But this will return a string formatted as Dollar - is there any way to format this to return Pound Sterling?

Thanks, Guy

4 Answers 4

7

Change the CurrentCulture as @Steve suggests or just use it like this:

Return itemValue.ToString("C", System.Globalization.CultureInfo.GetCultureInfo("en-gb"))
0
4

Before asking for the formatting change the CurrentCulture of your thread

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB")
2
  • Look also to the solution from @acfrancis. It is preferable if you need to change only in few places and keep the default for everywhere else
    – Steve
    Oct 28, 2013 at 11:39
  • Nice one Steve, Cheers.
    – guyh92
    Oct 28, 2013 at 11:40
2

The string formatter takes currency and number formatting from the current culture of your machine. You can either:

  1. Change the culture information on your computer
  2. Set the culture explicit in the formatting:

    Return String.Format(System.Globalization.CultureInfo.GetCultureInfo("en-GB"), "{0:C}", itemValue)

1
  • As above - all of these answers are perfect. Cheers, Guy.
    – guyh92
    Oct 28, 2013 at 11:40
0

There is simpler method. As float, double, decimal etc. type has own formatting, throughout ToString() method. For example:

double itemValue = 102.35;
Console.WriteLine(itemValue.ToString("C", new CultureInfo("en-GB")));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.