声明后缀为十进制类型 [英] Declaration suffix for decimal type
问题描述
如果我想使用十进制字面的code,我已经看到了存在后缀为M(其中M代表钱)。这是适合于任何小数或存在更一般的assigment(D代表双,这是舒尔不正确的事情,虽然直接的转换支持)。
If I want use a decimal-literal in code, I have seen that there exists the m-suffix (where m stands for money). Is this appropriate for any decimals or exists a more general assigment (d stands for double, that is for shure not the right thing although a direct conversion is supported).
object decimalValue=2m;
请注意,我把对象分配为例,因为在...的情况下
Please note, I took the object-assignment as example, because in the case of ...
decimal decimalValue=2;
...它隐含清楚,2应该是通过编译PTED为十进制除$ P $。
... its implicit clear that 2 should be interpreted as decimal through the compiler.
编辑: M 似乎是确定, MSDN 用途它作为例子小数类型。
m seems to be ok, msdn uses it as example for the decimal type.
推荐答案
记录在 C#语言规范,章2.4.4:
Documented in the C# language specification, chapter 2.4.4:
float f = 1.2f;
double d = 1.2d;
uint u = 2u;
long l = 2L;
ulong ul = 2UL;
decimal m = 2m;
没有对于int,字节,为sbyte,总之,USHORT。
Nothing for int, byte, sbyte, short, ushort.
这篇关于声明后缀为十进制类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!