我需要的是一种从列表中选择最后 100 个元素的方法,作为列表
public List<Model.PIP> GetPIPList()
{
if (Repository.PIPRepository.PIPList == null)
Repository.PIPRepository.Load();
return Repository.PIPRepository.PIPList.Take(100);
}
我得到这样的错误
“System.Collections.Generic.IEnumerable”到“System.Collections.Generic.List”。存在显式转换(是否缺少强制转换?)
最佳答案
somelist.Reverse().Take(100).Reverse().ToList();
这比订购便宜得多 :) 还保留了原始订购。
关于c# - 从 System.Collections.Generic.List c# 中选择 x 个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8005103/