var res = new int[1000000].Skip(999999).First();
It would be great if this query would just use the indexer instead of traversing 999999 entries.
I had a look into the System.Core.dll and noticed that in contrast to Skip()
, the Count()
extension method is optimized. If the IEnumerable
implements ICollection
then it just calls the Count
property.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…