促销的规则是"当操作数具有不同类型时,自动二进制数字促销发生,较小的操作数类型转换为较大的".但操作数是相同类型的,例如,
byte=byte+byte // Compile time error... found int..
Run Code Online (Sandbox Code Playgroud)
那为什么会这样呢?
我必须使用WinForms在VS2008 .net 3.5中使用以下代码:
byte percent = 70;
byte zero = 0;
Bitmap copy = (Bitmap)image1.Clone();
...
Color oColor = copy.GetPixel(x, y);
byte oR = (byte)(oColor.R - percent < zero ? zero : oColor.R - percent);
Run Code Online (Sandbox Code Playgroud)
当我离开(byte)最后一行代码的" "时,我收到编译器错误,说它"无法隐式转换类型int"到' byte'.如果一切都是类型byte并且byte是整数类型...那么我为什么需要演员?