.Net中的“Double”和“double”之间是否存在有意义的差异?

时间:2021-10-18 16:35:30

As regards best practices, is there a meaningful difference between using:

至于最佳实践,使用之间是否存在有意义的差异:

Double d;

and

double d;

I know best practices are fraught with contradictions, so I know the answers may vary here. I just want to know the pragmatic difference between the two.

我知道最佳实践充满了矛盾,所以我知道答案可能会有所不同。我只是想知道两者之间的实用差异。

5 个解决方案

#1


14  

There is no difference. double is just an alias for System.Double in C#.

没有区别。 double只是C#中System.Double的别名。

Note that VB.NET doesn't have the same aliasing (int for System.Int32, double for System.Double, etc), so the aliasing is just applicable to C#, not .NET as a whole.

请注意,VB.NET没有相同的别名(System.Int32的int,System.Double的double等),因此别名仅适用于C#,而不是整个.NET。

#2


10  

No, there's no difference: double is a C# keyword that's an alias for the System.Double type.

不,没有区别:double是C#关键字,它是System.Double类型的别名。

#3


1  

a bit difference here.

这里有点不同。

-You can have class,parameter,var named "Double" but if u want to name it "double" u must type @double.

- 您可以将class,parameter,var命名为“Double”,但如果您想将其命名为“double”,则必须键入@double。

-You can use Qualifier for Double but not for double. ex

- 你可以使用Qualifier for Double但不能用于double。前

System.Double d; //Correct
System.double d; //incorrect. Compiler error: Identifier expected for "System." .
Double Double,@double;//Correct
double double;//incorrect ,Identifier expected for both doubles

the same thing for classes and parameters....also the same for String-string,Boolean-bool .....

对于类和参数也是一样的....对于String-string也是一样的,Boolean-bool .....

#4


0  

In C# the Double and double are the same, however Double guranateed to be the same across all .NET platforms, and as far as I remember the double IS the same on all platform, but is not guaranteed as such (despite being it de facto).

在C#中,Double和double是相同的,但是Double在所有.NET平台上都是相同的,并且据我所知,双IS在所有平台上都是相同的,但不能保证这样(尽管事实上它是这样的) )。

#5


0  

Actually... after disassemble I found out that System.Double is a wrapper around double... So double is not a "shortcut" to System.Double.

实际上......在反汇编之后我发现System.Double是一个双重包装器...所以double不是System.Double的“快捷方式”。

#1


14  

There is no difference. double is just an alias for System.Double in C#.

没有区别。 double只是C#中System.Double的别名。

Note that VB.NET doesn't have the same aliasing (int for System.Int32, double for System.Double, etc), so the aliasing is just applicable to C#, not .NET as a whole.

请注意,VB.NET没有相同的别名(System.Int32的int,System.Double的double等),因此别名仅适用于C#,而不是整个.NET。

#2


10  

No, there's no difference: double is a C# keyword that's an alias for the System.Double type.

不,没有区别:double是C#关键字,它是System.Double类型的别名。

#3


1  

a bit difference here.

这里有点不同。

-You can have class,parameter,var named "Double" but if u want to name it "double" u must type @double.

- 您可以将class,parameter,var命名为“Double”,但如果您想将其命名为“double”,则必须键入@double。

-You can use Qualifier for Double but not for double. ex

- 你可以使用Qualifier for Double但不能用于double。前

System.Double d; //Correct
System.double d; //incorrect. Compiler error: Identifier expected for "System." .
Double Double,@double;//Correct
double double;//incorrect ,Identifier expected for both doubles

the same thing for classes and parameters....also the same for String-string,Boolean-bool .....

对于类和参数也是一样的....对于String-string也是一样的,Boolean-bool .....

#4


0  

In C# the Double and double are the same, however Double guranateed to be the same across all .NET platforms, and as far as I remember the double IS the same on all platform, but is not guaranteed as such (despite being it de facto).

在C#中,Double和double是相同的,但是Double在所有.NET平台上都是相同的,并且据我所知,双IS在所有平台上都是相同的,但不能保证这样(尽管事实上它是这样的) )。

#5


0  

Actually... after disassemble I found out that System.Double is a wrapper around double... So double is not a "shortcut" to System.Double.

实际上......在反汇编之后我发现System.Double是一个双重包装器...所以double不是System.Double的“快捷方式”。