Search code examples
c#asp.net.netglobalizationcultureinfo

overriding default format provider of a culture


I am looking for a way to override default decimal.ToString("c") method calls. I have written my custom format provider and it works when I do something like decimal.ToString(myprovider) but is there any way to override the default provider to route decimal.ToString("c") calls through my custom provider? Please note that its not about NumberFormat thing it works and I know I can override it. Its about the actual formatter that uses number format info and plugs it in output. The final goal is to do some calculation upon values while formatting.

Thanks


Solution

  • One way to achieve this was to write your custom provider and then change the number format provider for current thread. This will route all decimal.ToString("c") to your custom provider and format according to your codes.