I have integer list in C#. I need a method that, to give startIndex and step parameters and to take sublists from that. When reach to end, cross to begin of list. like circle
public List<int> GetSomeInt(List<int> mainList, int startIndex, int step )
{
...
}
For example, list elements are 4, 2, 85, 6, 7, 89, 1, 0, 36, 47, 11, 75. I give startIndex=3 and step=5 to method and I get so results:
result1 - 6, 7, 89, 1, 0
result2 - 36, 47, 11, 75, 4
result3 - 2, 85, 6, 7, 89, 1
result4 - 0, 36, 47, 11, 75
result5 - 4, 2, 85, 6, 7
result6 - 89, 1, 0, 36, 47
........................
How I get so successive sub-elements of list?
You could use
Queueto do round shift then get the result by LINQTake: