Count Non Zero Bytes
using System; internal static class Utils { internal static int CountNonZeroBytes(this byte[] arr) { int z = 0; for (int i = 0; i < arr.Length; i++) if (arr[i] == 0) z++; return arr.Length - z; } }