首先用点表示小数,然后用逗号表示

Ser*_*lok 5 c# asp.net-core-mvc asp.net-core asp-net-core-spa-services

我发现很多解决方案都是用逗号开头,然后是指向,我想要这样的东西: 133.000,00

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

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

在第二种格式中,我只会 133000.00

Mar*_*ell 5

您可能是说(之后var culture = CultureInfo.CreateSpecificCulture("da-DK");

var s = price.ToString("#,##0.00####", culture);
Run Code Online (Sandbox Code Playgroud)

要么:

var s = string.Format(culture, "{0:#,##0.00####}", price);
Run Code Online (Sandbox Code Playgroud)

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