Reputation: 45
DataRowCollection : InternalDataCollectionBase
InternalDataCollectionBase : ICollection, IEnumerable
So , DataRowCollection indirectly inherites IEnumerable. Generally , If a class inherites IEnumerable we can apply linq operations . But in DataRowCollection this fails . Why?
Upvotes: 0
Views: 132
Reputation: 5194
Most of the Linq extension methods (from System.Linq.Enumerable) operate on a generic System.Collections.Generic.IEnumerable<T>, rather than the non-generic System.Collections.IEnumerable that InternalDataCollectionBase implements. That's why you use the Cast
(or OfType
) extension method to turn your IEnumerable
into an IEnumerable<DataRow>
.
Upvotes: 2