[英]Selecting a sequence of elements from the IList
I have a IList. 我有一个IList。 where the object PersonDetails consists of the persons name, address and phone number.
其中对象PersonDetails由人员名称,地址和电话号码组成。 The list consists of more than 1000 person details.
该列表包含1000多个人的详细信息。 I would like to display 50 PersonDetails per page.
我想每页显示50个PersonDetails。 Is there a way to select only 50 elements from the list, and return them.
有没有一种方法可以从列表中仅选择50个元素,然后返回它们。 For example.
例如。
myList.select(1,50)
myList.select(51, 100)
I am able to select only first 50 by using. 我只能使用来选择前50个。
myList.Take(50);
The entire list is at the wcf service, and i would like to get only fifty elements at a time. 整个列表位于wcf服务处,我想一次仅获取50个元素。
This will select second 50 elements (by skipping first 50): 这将选择后50个元素(跳过前50个元素):
var elements = myList
.Skip(50)
.Take(50)
.ToList();
Skip
method bypasses a specified number of elements in a sequence and then returns the remaining elements. Skip
方法绕过序列中指定数量的元素,然后返回其余元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.