0

我需要分开数字。

@model string
@{
    @String.Format("{0:### ### ###}", Int32.Parse(Model))
}

如何将空格更改为nbsp?编码阻碍了我。与号更改为& a m p ;

4

1 回答 1

1

您可以使用 Html.Raw 函数防止 Razor 自动对字符串进行编码:

@model string
@{
    @Html.Raw(string.Format("{0:### ### ###}", Int32.Parse(Model)))
}

显然你在使用这个函数时应该小心,但如果你只是输出一个整数,你应该没问题。

于 2012-06-19T16:06:24.470 回答