Is there any way to express this idea in C#? (Basically a generic type of a generic type)?
public static class ExtensionSpike
{
public static IEnumerable<T> Where<TCollection<T>>(this TCollection<T> sourceCollection, Expression<Func<T, bool>> expr)
where TCollection : class, IEnumerable<T>, INotifyCollectionChanged
{
throw new NotImplementedException();
}
}
The generic constraint might not be quite what you want, but is this basically what you’re looking for? This constrains TCollection to be an
IEnumerable<T>(although IEnumerable can be swapped for List/Collection/Etc…)Update: just changed my sample a little to better follow the method–I’d been confused and didn’t realize you wanted a
Where()method, I assumed it was your generic-constraintwhere.