全球化自定义数字格式 - 可变小数点
我正在尝试更改公司应用程序中现有的数字格式,以使其对国际用户更具可读性。这是一个股票交易应用程序,因此大多数股票价格的数字精确到小数点后两位,就像这样-> 17.23 我们还可以得到精确到小数点后 4 位的刻度,因此细价股票可能是 0.0341。我们用于股票的原始字符串格式是“#,##0.00##”,这将为我们提供我们想要的格式(本质上是修剪“0”)。这里的问题是“,”和“.”。被强加给用户,在许多其他国家/地区,千位分隔符是“.”。小数点为“,”。老板不想对所有号码都使用“N4”,尽管这可以解决全球化问题。是否可以有一个全球化的自定义字符串格式?
除了编写一些中间人代码来国际化原始方式或其他 string.format 方法格式化的数字之外,还有其他选择吗?
I'm trying to alter the existing number formatting in my company's application to make it more readable for international users. This is a stock trading application, so most stock prices come in with numbers precise to 2 decimal points, like so-> 17.23 We could also get ticks in that have precision out to 4 decimal points, so a penny stock might be 0.0341. The original string format that we were using for stocks was "#,##0.00##" Which would give us the format we wanted (essentially trimming '0's). The problem here is the ',' and '.' are forced onto the user, where in many other countries the thousands separator is '.' and the decimal point is ','. Boss man doesn't want to use "N4" for all numbers, even though this would resolve the globalization issue. Is it possible to have a globalized custom string format?
Other options besides writing some middle man code to internationalize numbers formatted the original way or another string.format method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看这个:
Check this out:
自定义格式字符串中的
、
和.
已转换为当前区域性的正确分隔符。您不需要更改您的代码。请参阅 MSDN。The
,
and.
in the custom format string already translate into the correct separators for the current culture. You should not need to change your code. See MSDN.