且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是双言下之意的目的是什么?

更新时间:2022-05-13 22:24:18

没有

25.50 的类型是一个独立的表达双击,而不是小数。结果
编译器不会看到你试图将其分配到一个小数变量并把它解释为十进制。

25.50 is a standalone expression of type double, not decimal.
The compiler will not see that you're trying to assign it to a decimal variable and interpret it as a decimal.

除了lambda表达式,匿名方法和条件运算符,所有的C#表达式有一个完全不依赖于上下文中的固定式

Except for lambda expressions, anonymous methods, and the conditional operator, all C# expressions have a fixed type that does not depend at all on context.

想象一下,你希望它是什么,如果编译器确实会发生什么,你叫 Math.Max(1,2)。结果
Math.Max 有需要重载 INT 双击小数。哪一个会叫?

Imagine what would happen if the compiler did what you want it to, and you called Math.Max(1, 2).
Math.Max has overloads that take int, double, and decimal. Which one would it call?