How can I check if a byte[] contains only 0's? I do not want to send the array over the network if it only contains zeroes:
byte[] bytesToBeSend = e.GetAudioSamples;
// Send test data to the remote device.
Send(client, bytesToBeSend);
Insert this test before your Send
request and use an if
test:
bool hasAllZeroes = bytesToBeSend.All(singleByte => singleByte == 0);
if (!hasAllZeroes) {
Send(client, bytesToBeSend);
}
Make sure that you've included LINQ:
using System.Linq;