I have a list of this custom class and I'm trying to find out how to use a linq statement in C# to break that list into groups of 50 items each. Any ideas?
List<Symbol> symbolList = new List<Symbol>(); public class Symbol { public string Symbol { get; set; } public string Market { get; set; } }
TakeandSkipmight help.GroupBybut 1: Unfortunatly, you should copy the result toList/Arrayetc 2: It looks a few difficult for understandingList<int> list = new List<int>(Enumerable.Repeat(2, 249)); int count = 0; int groupNumber = 1; var test = list.GroupBy(item => count++ < 50 ? groupNumber : groupNumber += (count = 1)).ToList();