performance of linq extension method ElementAt
- by Fabiano
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