It doesn't look like Lynx is planning on updating his answer, so for future reference, bitwise operators work fine on byte
. They just return an int, which is not assignable to a variable of type byte
. You only need one cast here:
byte notb = (byte)~b;