c# - How i can split comma separated string in a group using LINQ -
i have string of comma separated ids 1,2,3,4,5,6,7,8,9...... etc.
please suggest how can split them in group of "quantity" means if quantity=3 group (list) ["1,2,3"], ["4,5,6"], ["7,8,9"] etc.
range of quantity 1-75.
try this:
var quantity = 3; yourlist.select((x, i) => new { index = i, value = x }) .groupby(x => x.index / quantity ) .select(x => x.select(v => v.value).tolist()) .tolist();
Comments
Post a Comment