The only explanation I can think of is that the compiler is smart enough to realize there is an implicit operator that will convert long to decimal, that it can use to satisfy the explicit conversion between Program and decimal when Program can only convert to long.
http://www.un.org。 这里我们是;数字类型之间的换算成文:
6.1.2 默示数字换算
默示数字换算为:
· 从by到 short、 in、长、浮、两倍或小.。
· From byte to short, ushort, int, uint, long, ulong, float,
double, or decimal.
· 从短期到内、长期、浮动、双重或 de。
· From ushort to int, uint, long, ulong, float, double, or
decimal.
· 从中长期来看,浮、双倍或小数。
· 从int到长、ul、浮、两倍或小.。
•From long torot, Double, or decimal.
· 从ul到浮、翻一番或 de。
· From char to ushort, int, uint, long, ulong, float, double,
or decimal.
· 从浮到两倍。
Conversions from int, uint, long, or ulong to float and from long or
ulong to double may cause a loss of precision, but will never cause a
loss of magnitude. The other implicit numeric conversions never lose
any information.
There are no implicit conversions to the char type, so values of the
other integral types do not automatically convert to the char type.
因此,C#在转换方案与数字之间时知道,它可以暗中从任何数字类型转换成正数,因此,在进行这种明确转换时,它将寻找任何能够将方案变成数字型的经营者。
什么是令人感兴趣的,如果你也明确转而回48岁,情况如何? 汇编者会选取什么?