Selecting a sequence of elements from an IList

I have an IList. where the PersonDetails object consists of a name, address, and phone number. The list consists of over 1000 personal data. I would like to display 50 PersonDetails per page. Is there a way to select only 50 items from the list and return them. For instance.

myList.select(1,50)
myList.select(51, 100)

      

I can only select the first 50 using. myList.Take(50);

The entire list is in the wcf service and I would only like to get fifty items at a time.

+2


a source to share


1 answer


This will select the second 50 items (skipping the first 50):

var elements = myList
    .Skip(50)
    .Take(50)
    .ToList();

      



Skip

the method
traverses a specified number of elements in the sequence and then returns the remaining elements.

+5


a source







All Articles