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