可能重复: C# XOR on two byte variables will not compile without a cast
为什么在这段C#代码中出现编译错误?
void test()
{
ushort a = 0;
ushort b = 0;
ushort c = a ^ b; //ERROR
}错误CS0266:不能隐式地将类型'int‘转换为'ushort’。存在显式转换(是否缺少强制转换?)
发布于 2012-10-10 11:49:59
看看这个:C# XOR on two byte variables will not compile without a cast
基本上,使用位运算符,任何小于int的操作数都会自动转换为int。
https://stackoverflow.com/questions/12818539
复制相似问题