performance of linq extension method ElementAt
Posted
by Fabiano
on Stack Overflow
See other posts from Stack Overflow
or by Fabiano
Published on 2010-04-28T15:24:45Z
Indexed on
2010/04/28
15:33 UTC
Read the original article
Hit count: 567
Hi
The MSDN library entry to Enumerable.ElementAt(TSource)
Method says
"If the type of source implements IList, that implementation is used to obtain the element at the specified index. Otherwise, this method obtains the specified element."
Let's say we have following example:
ICollection<int> col = new List<int>() { /* fill with items */ };
IList<int> list = new List<int>() { /* fill with items */ };
col.ElementAt(10000000);
list.ElementAt(10000000);
Is there any difference in execution? or does ElementAt recognize that col
also implements IList<> although it's only declared as ICollection<>?
Thanks
© Stack Overflow or respective owner