но в целом ход мыслей правильный..подчеркну.. себя цитирую..
static int SearchBytes(int[] haystack, int[] needle)
{
for (int i = 0, k = 0; i <= haystack.Length - needle.Length; i++)
{
for (k = 0; k < needle.Length; k++)
if (needle[k] != haystack[i + k])
break;
if (k == needle.Length)
return i;
}
return -1;
}
static int SearchBytes(int[] haystack, int[] needle)
{
for (int i = 0, k = 0; i <= haystack.Length - needle.Length; i++) {
for (k = 0; k < needle.Length; k++) if (needle[k] != haystack[i + k]) break;
if (k == needle.Length) return i;
}
return -1;
}