For example consider:
var hset = new HashSet<int>();
// Fill the hset.
var enumerable = hset as IEnumerable<int>;
bool enumerable.Contains(0);
Does LINQ use the fact that the HashSet has an efficient implementation of Contains
, or does itsimply operate on the enumerator as one would expect?
The reason I'm asking is that the component I'm currently working on has a number of properties that are IEnumerable<T>
, but the previously developer always converts whatever data structure he is using to create the enumerable object to an array before assigning it to the property. I'm not sure if this is good practice or a complete waste of time.