NumberFormat object flaw?
- How can you use a NumberFormat object to get the "pence" symbol for a culture, i.e. en-GB would give "p" and en-US would give "¢". I've been looking through the class in visual studio and can't find anything relating to this, i've also gone through the different ToString() format methods and i can't find anything their either.
If you have an answer please reply here and drop a comment on my blog
Cheers
Answers
Windows locale/culture only recognizes currency at the 100 level (i.e. dollars or pounds). You'll have to manage formatting cents at the application level.
- I think because "pence" or cent symbol is an exception to the rule and not the standard. In many cases monetary systems don't have "pence" currency. For example the smallest denomination for the Japanese Yen is 1 Yen. This is true in many other currencies. You'll also see that in all cases where you have a "pence" symbol, you can also format it as "$"0.00. From what I've seen the culture info doesn't store the pence symbol.
All Replies
- I dont think number format can handle that, you need to write your own code to do that.
- The problem with writing your own code to do it is if you want to add another currency to your table and they have a different symbol for their "pence", "cent" etc then it will require a code change to hard code the new symbol where as the cultureinfo object will handle any new cultures dynamically.
If the NumberFormat object can't do this then is there another way of getting the pence / cent symbol dynamically based on the users culture? Windows locale/culture only recognizes currency at the 100 level (i.e. dollars or pounds). You'll have to manage formatting cents at the application level.
- I think because "pence" or cent symbol is an exception to the rule and not the standard. In many cases monetary systems don't have "pence" currency. For example the smallest denomination for the Japanese Yen is 1 Yen. This is true in many other currencies. You'll also see that in all cases where you have a "pence" symbol, you can also format it as "$"0.00. From what I've seen the culture info doesn't store the pence symbol.
- Thanks for your answers, i suppose it makes sense when you think about cultures that don't have a "pence" denomination.

