score:2

Accepted answer

pure linq:

var arr = new byte[] { 1, 2, 3, 4, 5, 6 };

var res = arr.zip(arr.skip(1), (a, b) => new { a, b }).select((x, i) => new { x, i })
    .firstordefault(v => v.x.a == 3 && v.x.b == 4);


if (res != null)
{
    console.writeline(res.i);
}

score:1

given how you said you want to search for bytes in a list, i'm assuming you have an object of list<byte>, named list, and a byte[], named bytes.

list<byte> list = new list<byte>();
byte[] bytes = { 0x01, 0x02 };

list.where((b, i) => (list.count() >= i + 1 ? false : (b == bytes[0] && list[i + 1] == bytes[1]))).first();

the ternary expression ensures you don't have an arrayoutofboundsexception


Related Query

More Query from same tag