在C#中的十进制和十进制不同? [英] In c# are Decimal and decimal different?
问题描述
在C#中,如果我使用小数
(小写字母'D')时,IDE显示它在深蓝色(如 INT
)。如果我使用小数
(大写的'D')时,IDE显示它水鸭(如类名)。在这两种情况下,工具提示结构System.Decimal
。
In c# if I use decimal
(lower case 'd'), the IDE shows it in dark blue (like int
). If I use Decimal
(upper case 'd'), the IDE shows it in teal (like a class name). In both cases the tooltip is struct System.Decimal
.
有什么区别吗?一个首选
Is there any difference? Is one "preferred"?
推荐答案
都能跟得上?;相同。 小数
终止的定义的作为别名 System.Decimal
,一般首选,除了公共方法名称,你应该使用合适的名称( ReadDecimal
等) - 因为你的来电者可能不是C#。这是更明显的 INT
VS ReadInt32
等
Nope; identical. decimal
is defined as an alias to System.Decimal
, and is generally preferred, except in public method names, where you should use the proper name (ReadDecimal
, etc) - because your callers might not be C#. This is more noticeable in int
vs ReadInt32
, etc.
有肯定不是Java风格的拳击差异。
There certainly isn't the Java-style boxing difference.
(当然,如果你做类似声明更为命名空间-local 小数
,做完全不同的东西,然后有是的差异,但是这将是愚蠢的)。
(of course, if you do something like declare a more-namespace-local Decimal
that does something completely different, then there are differences, but that would be silly).
这篇关于在C#中的十进制和十进制不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!