private int arrayFind(byte[] haystack, byte[] needle) { int i = Array.IndexOf(haystack, needle[0]); while (i > -1) { for (int j = 0; j < needle.Length && (j + i) < haystack.Length; j++) { if (needle[j] != haystack[i + j]) break; if (j == needle.Length - 1) return i; } i = Array.IndexOf(haystack, needle[0], i + 1); } return -1; }