5

我找到了很多第一个逗号然后指向的解决方案,我想要这样的东西:133.000,00

到目前为止我尝试了什么:@item.Price.ToString("C3", System.Globalization.CultureInfo.CreateSpecificCulture("da-DK"))

@String.Format("{0:#.##0,######}", item.Price)

在第二种格式中,我只得到133000.00

4

2 回答 2

5

您可能的意思是(在 之后var culture = CultureInfo.CreateSpecificCulture("da-DK");

var s = price.ToString("#,##0.00####", culture);

或者:

var s = string.Format(culture, "{0:#,##0.00####}", price);

在这两种情况下,您都需要传入要使用的文化,并且:.在格式字符串中表示“文化的小数点标记”,,在格式字符串中表示“文化的千位分隔符标记”。注意我.00##最后使用了因为你似乎想要两位小数,即使它们是零。

于 2019-03-07T11:13:56.300 回答
0

像这样的东西应该工作:

item.Price.ToString("#,#0.00", System.Globalization.CultureInfo.CreateSpecificCulture("da-DK"))
于 2019-03-07T11:21:14.370 回答