I'm currently working on an application where the format of the numbers needs to be in the english format (#,##0.00), but currencies needs to be displayed in € .
Now I can set the Culture in my web.config on en-gb and just put a label behind it with € as the text. (I don't like this).
So my question is, can I modify the way of displaying the number (or currency) on application level and not formatting each string? I don't want to specify my own custom format in each decimal I create.
The ToString(String) method of int supports output currency format
Response.Write(i.ToString("c")); // The parameter "c" means convert it to currency format
here is the example:
int i = 100;
// Sets the CurrentCulture to French in France.
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
Response.Write(i.ToString("c"));
// Sets the CurrentCulture to French in France, using the
// CultureInfo constructor that takes a useUserOverride parameter.
// Sets the useUserOverride value to false.
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR",
false);
// Displays i formatted as default currency for the CurrentCulture.
// On a version of Windows prior to Windows XP, this will override an
// incorrect default setting of "F" and display the euro symbol (€).
Response.Write(i.ToString("c"));
And output:
100,00 F
100,00 €
Please check the example of this link for more information:
Zhao Ji Ma
Sincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
Kristof Renn...
Member
120 Points
26 Posts
NumberFormatInfo
Dec 19, 2006 01:38 PM|LINK
Hi there,
I'm currently working on an application where the format of the numbers needs to be in the english format (#,##0.00), but currencies needs to be displayed in € .
Now I can set the Culture in my web.config on en-gb and just put a label behind it with € as the text. (I don't like this).
So my question is, can I modify the way of displaying the number (or currency) on application level and not formatting each string? I don't want to specify my own custom format in each decimal I create.
Thanks
Zhao Ji Ma -...
All-Star
23104 Points
2380 Posts
Re: NumberFormatInfo
Jan 17, 2007 05:58 AM|LINK
Response.Write(i.ToString("c")); // The parameter "c" means convert it to currency formatSincerely,
Microsoft Online Community Support
“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”