C#C
C#4y ago
Matt

Union? of two binary arrays

Let's say we have two byte arrays:
byte[] ba1 = { 01, 01, 00, 00 };
byte[] ba2 = { 01, 00, 01, 00 };

I want to perform some operation on the arrays such that if the first byte in BOTH arrays is 0, then the resulting array's first byte is 0 but if EITHER byte is a 1, then the resulting array's first byte is a 1. (Extend this logic to each byte) Thus, the resulting array should be:
byte[] baRes = { 01, 01, 01, 00 }

Is there any nice function that will do this for me?
Was this page helpful?