Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to take elements from range with lambda expressions and linq?

Tags:

c#

lambda

linq

How can I take elements by range with lambda and linq?

For example:

I have a table with 54 elements. I just want to take elements from possition 1-10, or 10-20 or 20-30 etc - generally by some numeric range.

How can I do this?

like image 594
whoah Avatar asked Nov 28 '22 16:11

whoah


1 Answers

List<int> list = new List<int>();
IEnumerable<int> interval = list.Skip(a).Take(b);
like image 81
Ahmed KRAIEM Avatar answered Dec 18 '22 23:12

Ahmed KRAIEM