using System.Collections.Generic;
public static class ArrayExtensions
public static IEnumerable<int> StartingIndex(this byte[] x, byte[] y)
IEnumerable<int> index = Enumerable.Range(0, x.Length - y.Length + 1);
for (int i = 0; i < y.Length; i++)
index = index.Where(n => x[n + i] == y[i]).ToArray();
static void Main(string[] args)
byte[] x = new byte[] { 1, 2, 3, 3, 3, 6, 3, 3, 3 };
byte[] y = new byte[] { 3, 3 };
int[] expected = new int[] { 2, 6 };
IEnumerable<int> result = x.StartingIndex(y);
Console.WriteLine("Result: " + string.Join(", ", result));
Console.WriteLine("Expected: " + string.Join(", ", expected));
Console.WriteLine("Result matches expected: " + Enumerable.SequenceEqual(result, expected));