C # (common to common)?

Is there any way to express this idea in C #? (Basically a generic 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(); } } 
+4
source share
1 answer

The general limitation may not be exactly what you want, but is it basically what you are looking for? This limits TCollection to IEnumerable<T> (although IEnumerable can be replaced with List / Collection / Etc ...)

 public static IEnumerable<T> Where<T, TCollection>(this TCollection sourceCollection, Expression<Func<T, bool>> expr) where TCollection : IEnumerable<T>, INotifyPropertyChanged { throw new NotImplementedException(); } 

Update: only slightly changed my selection to better follow the method - I was confused and did not understand that you need the Where() method, I assumed that this is your general, where restriction.

+5
source

All Articles