I have a list with N results, I would need to make some changes in linq so this list would return N lists of only 3 underlying results. Any idea?
I have a list with N results, I would need to make some changes in linq so this list would return N lists of only 3 underlying results. Any idea?
You can use the following code:
var resultados = lista.Select((x, i) => new { Index = i, Value = x })
.GroupBy(x => x.Index / 3)
.Select(x => x.Select(v => v.Value).ToList())
.ToList();
With this you break your list into N lists of 3 results.