从 .ToString("{0:C}") 格式的数字中删除 $ [英] Remove $ from .ToString("{0:C}") formatted number
问题描述
基本上我是这样格式化数字
@String.Format("{0:C}", Model.Price)
结果是 $2,320,000.00
然而,我想要的结果分别是 2,320,000.00
没有 $
.我怎样才能做到这一点,同时仍然利用 .nets 本地化处理?
编辑
如果我想改变我的班级,当有人试图获得 Price
时,他会得到这种格式化的 price .这是我的课
公共类列表:DomainObject{公共十进制价格{得到;放;}公共十进制委员会{得到;放;}}
使用 N
而不是 C
作为您的 格式说明符:
@String.Format("{0:N}", Model.Price)
<块引用>
C"或c"货币结果:货币值.
123.456(C",美国)-> 123.46 美元
N"或n"数字结果:整数和十进制数字、组分隔符和小数
1234.567(N",美国)-> 1,234.57
即你得到一个货币符号是因为你要一个.
Basically I am formatting numbers like this
@String.Format("{0:C}", Model.Price)
The result is $2,320,000.00
My desired result, however, is 2,320,000.00
just without $
, respectively. How can I attain this, while still taking advantage of .nets localization handling?
Edit
and what if i want that change my class so that when ever a person try to get Price
, he gets this kind of formatted price . Here is my class
public class Listing : DomainObject
{
public decimal Price { get; set; }
public decimal Commission { get; set; }
}
Use N
instead of C
as your format specifier:
@String.Format("{0:N}", Model.Price)
"C" or "c" Currency Result: A currency value.
123.456 ("C", en-US) -> $123.46
"N" or "n" Number Result: Integral and decimal digits, group separators, and a decimal
1234.567 ("N", en-US) -> 1,234.57
I.e. you were getting a currency symbol because you were asking for one.
这篇关于从 .ToString("{0:C}") 格式的数字中删除 $的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!