What i need is a way to select the last 100 elements from a list, as list
public List<Model.PIP> GetPIPList()
{
if (Repository.PIPRepository.PIPList == null)
Repository.PIPRepository.Load();
return Repository.PIPRepository.PIPList.Take(100);
}
I get error like this
‘System.Collections.Generic.IEnumerable’ to ‘System.Collections.Generic.List’. An explicit conversion exists (are you missing a cast?)
If your list is large, you’ll get the best performance by rolling your own:
Why is this faster than using Skip()? If you have a list with 50,000 items, Skip() calls MoveNext() on the enumerator 49,900 times before it starts returning items.
Why is it faster than using Reverse()? Because Reverse allocates a new array large enough to hold the list’s elements, and copies them into the array. This is especially good to avoid if the array is large enough to go on the large object heap.