Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more

You have a list of objects, and the length is N.
You want to take all the possible M-length slots with consecutive objects.
Suppose we have myList, we want all the 3-length slots:

List<int> myList = new List<int>() {32, 645, 3, 35, 75, 435, 423, 13, 65, 8};
List<int[]> listOfSlots = new List<int[]>()
{
    new[] {32, 645, 3},
    new[] {645, 3, 35},
    new[] {3, 35, 75},
    new[] {35, 75, 435},
    new[] {75, 435, 423},
    new[] {435, 423, 13},
    new[] {423, 13, 65},
    new[] {13, 65, 8}
};
using System.Collections.Generic;
using System.Linq;

int M = 3;
List<int[]> results = Enumerable.Range(0, myList.Count - M + 1).Select(n => myList.Skip(n).Take(M).ToArray()).ToList();