c# - performance of linq extension method ElementAt -
the msdn library entry enumerable.elementat(tsource) method says
"if type of source implements ilist, implementation used obtain element @ specified index. otherwise, method obtains specified element."
let's have following example:
icollection<int> col = new list<int>() { /* fill items */ }; ilist<int> list = new list<int>() { /* fill items */ }; col.elementat(10000000); list.elementat(10000000); is there difference in execution? or elementat recognize col implements ilist<> although it's declared icollection<>?
thanks
the type of variable irrelevant elementat method - far it's concerned, it's declared ienumerable<t>, because that's parameter type is. (both calls bound same extension method.)
it's execution-time type of object tested in elementat.
Comments
Post a Comment