![](/img/trans.png)
[英]Is CultureInfo.CurrentCulture really necessary in String.Format()?
[英]String.format to change a decimal variable depending on CurrentCulture
我需要根据 CurrentCulture 更改变量的格式
变量是十进制
这是我当前的更改声明:
string auxst = String.Format(CultureInfo.CurrentCulture, "#,##0.00", variable);
我需要知道在第二个参数中放什么,以便发生这种情况:
Variable = 150.465,1242345
If CurrentCulture is "es ES"(spain) -> auxst = "150.465,1242345"
If CUrrentCulture is "en EN" -> auxst = "150,465.1242345"
谢谢你的帮助
如果您使用 CurrentCulture,请不要指定它。
您应该使用 Decimal.ToString():
Decimal variable = 15465.1242345M;
string auxst = variable.ToString("N");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.