C# · 12月 30, 2021


我正在使用第一种方式,而我的新公司正在使用第二种方式. double x = 1.99; double y = 9.02D;


解决方法 从 msdn:

By default,a real numeric literal on
the right-hand side of the assignment
operator is treated as double.
However,if you want an integer number
to be treated as double,use the
suffix d or D,for example: Copy

double x = 3D;

所以双倍x = 1.99没有区别;双y = 9.02D;