Can you use LINQ in an object that exposes only Add(), Remove(), Count(), Item() and GetEnumerator() from System.Collections.IEnumerator?
The existing Linq extension methods work on objects that implement IEnumerable
. I assume your object implements the non-generic IEnumerable
interface. In that case you can use the Cast
extension method to get a generic IEnumerable
wrapper. For instance, if the elements are of type int
:
var wrapper = myObject.Cast();
You can now use Linq on the wrapper