-1

如何更改格式货币“。” 到 ',' 在 asp.net MVC4 例如:10,000 thay cho 10.000 我有文件模板 @Model.ToString("n0")

4

2 回答 2

0

您可以使用允许指定区域性的 ToString() 重载。

// Use the culture you desire instead of en-US
culture = CultureInfo.CreateSpecificCulture("en-US"); 
Console.WriteLine(value.ToString(specifier, culture));

http://msdn.microsoft.com/en-us/library/d8ztz0sa.aspx

于 2013-07-03T07:43:39.480 回答
0

看看这个链接:

http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.currencygroupseparator.aspx

您可以通过指定数字格式和修改示例代码和输出CurrencyGroupSeparator

using System;
using System.Globalization;

class NumberFormatInfoSample {

   public static void Main() {

      // Gets a NumberFormatInfo associated with the en-US culture.
      NumberFormatInfo nfi = new CultureInfo( "en-US", false ).NumberFormat;

      // Displays a value with the default separator (",").
      Int64 myInt = 123456789;
      Console.WriteLine( myInt.ToString( "N0", nfi ) );

      // Displays the same value with a specified separator.
      nfi.CurrencyGroupSeparator = ".";
      Console.WriteLine( myInt.ToString( "N0", nfi ) );

   }
}


/* 
This code produces the following output.

123,456,789
123.456.789
*/
于 2013-07-03T07:46:54.837 回答