I have a working website, where I use this expression everywhere.
我有一个工作网站,我到处都使用这个表达。
price.ToString("C")
It currently shows 2 decimal places, eg. $1.45
它目前显示2位小数,例如。 $ 1.45
Now I need the website to show 4 decimal places, eg. $1.4515
现在我需要网站显示4个小数位,例如。 $ 1.4515
Is there any easy way to change it globally?
有没有简单的方法可以在全球范围内改变它?
2 个解决方案
#1
20
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")
.
您无法修改格式说明符的默认行为,但可以在项目中执行全局搜索和替换。假设您正在使用Visual Studio,则可以执行全局搜索和替换(Ctrl-Shift-H)并将.ToString(“C”)替换为.ToString(“C4”)。
#2
4
Can you overwrite thread's CurrentCulture and set CurrencyDecimalDigits?
你能覆盖线程的CurrentCulture并设置CurrencyDecimalDigits吗?
#1
20
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")
.
您无法修改格式说明符的默认行为,但可以在项目中执行全局搜索和替换。假设您正在使用Visual Studio,则可以执行全局搜索和替换(Ctrl-Shift-H)并将.ToString(“C”)替换为.ToString(“C4”)。
#2
4
Can you overwrite thread's CurrentCulture and set CurrencyDecimalDigits?
你能覆盖线程的CurrentCulture并设置CurrencyDecimalDigits吗?