Random example:
ConfigurationElementCollection
.Net has tons of these little WhateverCollection
classes that don't implement IEnumerable<T>
, which means I can't use Linq to objects with them out of the box.
Even before Linq, you'd think they would have wanted to make use of generics (which were introduced all the way back in C# 2 I believe)
It seems I run across these annoying little collection types all the time. Is there some technical reason?
OfType
orCast
if the collection tends to contain a strong type, so long as it at least implementsIEnumerable
(non-generic).OfType
/Cast
yield genericIEnumerable<T>
instances, and thus opens the rest of the LINQ operators.