Linq Select 5 items each time based on our enumerator
Our List e.g "theList"
has 100 items, Want to go through the list and Select 5 items in each iterations,
Sample Code, which we want to change this into our desired result :
theList = dt.AsEnumerable() .Select(row => new CustItem { Name = row.Field<string>("tName"), Title = row.Field<string>("tTitle"), }).ToList();
We should Iterate it within a loop and process on the selected 5 items each time, or pass it to our other methods :
something like it :
for (int i=0; i < 20 ; i++)
I want to use "i"
enumerator on the linq select
statement and make a multiplicity to make the boundaries of our new resultset.
for (int i=0; i < 20 ; i++) { var fiveitems = theList.Skip(i*5).Take(5); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With