String.Format是否考虑语言环境? [英] String.Format consider locale or not?
问题描述
String.Format是否确实可以通过两种方式工作: 如果我们使用内置格式(例如C,N,P ...),它将考虑语言环境设置吗? 如果我们使用#,## 0.000之类的自定义格式代码,它将不会考虑区域设置吗?
Is it true that String.Format works 2 ways: if we use built-in format such as C, N, P.... it will take locale settings into account? if we use custom format code such as #,##0.000 it will NOT take locale settings into account?
在我的代码中,我使用这样的方法
In my code, I use method like this
String.Format("{0:#.## 0,000}",值);
String.Format("{0:#.##0,000}", value);
因为我的国家使用逗号作为小数点分隔符
because my country use comma as decimal separator
但结果仍然是:1,234.500,就好像将点视为小数点分隔符一样.
but the result still is: 1,234.500 as if it consider dot as decimal separator.
请帮助!
推荐答案
您要使用
使用 因为您在河内(根据个人资料),所以我使用的越南代码是 Since you're in Hanoi (from profile), I used Vietnam's code, which is 这篇关于String.Format是否考虑语言环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!String.Format
:>
String.Format(new CultureInfo("vi-VN"), "N", value);
vn-VN
.vn-VN
.