I experimented a bit with generators in C #, and I had a problem when I want to pass a generic type as a constrained type parameter to implement a generic interface whose type I don't know.
Here is my example:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication3 { class Program { interface IGenericCollection<T> { IEnumerable<T> Items { get; set; } } abstract class GenericCollection<T> : IGenericCollection<T> { public IEnumerable<T> Items { get; set; } }
I read a few posts here and everyone told me that this is not possible due to C # and CLR limitations. But what would be the right way to do this?
source share