繁体   English   中英

String.format 根据 CurrentCulture 更改十进制变量

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM