Subtracting from a byte array (LED matrix project)

I have Led Matrix project where I want to show a led display and then (using timer) the opposite of the led display (the negative). I wanted to use a logical NOT but it does not exist so wanted to change the byte array value for each 8 Leds line to 15 minus the value but I can’t subtract a byte array value from an integer (15). Also, .NET MF doesn’t allow for conversations from byte to int and vise versa. Below is the line of code that get’s the values into my byte array to be displayed. How can I change these byte array values (by subtracting them from 15 or other) to get values that are the opposite binary representation (Logical NOT)


byte[] displayLed = new byte[] { 0x0, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e };

@ Gad - I think you really want the bitwise not which is tilda ~
If you need to force a type coersion you would use a cast, here is an example


byte b = 45;
int i = b;  // no cast required because conversion from byte to int is lossless so the compiler will do an implicit cast

byte b2 = (byte)i; // since conversion from int to byte is potentially lossy, the cast needs to be explicit.

and casting between byte and integer variables is supported.

PERFECT! thank you both