I have a working website, where I use this expression everywhere.
price.ToString("C")
It currently shows 2 decimal places, eg. $1.45
Now I need the website to show 4 decimal places, eg. $1.4515
Is there any easy way to change it globally?
On the Home tab, click the Dialog Box Launcher next to Number. Tip: You can also press Ctrl+1 to open the Format Cells dialog box. In the Format Cells dialog box, in the Category list, click Currency or Accounting. In the Symbol box, click the currency symbol that you want.
By using a button: Select the cells that you want to format. On the Home tab, click Increase Decimal or Decrease Decimal to show more or fewer digits after the decimal point.
You can't modify the default behavior of the format specifier, but you can do a a global search-and-replace in your project. Assuming you're using Visual Studio, you can do a global search-and-replace (Ctrl-Shift-H) and replace .ToString("C")
with .ToString("C4")
.
Can you overwrite thread's CurrentCulture and set CurrencyDecimalDigits?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With