c# 按位求补运算符
byte i= 0;
Console.WriteLine(~i);//为什么输出-1,不是应该输出255吗?
[解决办法]
返回int值...
----------
操作数byte返回int值...编译器会隐式转换它的类型...
[解决办法]
byte i = 0;
i = (byte)~i;
需要强制转换
[解决办法]
byte i = 0;
Console.WriteLine( "{0:x8} ", ~i);
输出是:
ffffffff
和Console.WriteLine用的Format 有关