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?
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?
if what you want is pageing,
Use
List<T>.GetRange(int index, int count);
Don't
Skip
andTake
, justGetRange
!Hope this helps!
You can use
Enumerable.Skip
andEnumerable.Take
methods;Output will be;
Here is a
DEMO
.You can use
Like this: