Suppose I have a class
Class Apple<T> where T: IComparable<int>{}
Now while creating an object for Apple I'll do it like
Apple<int> obj = new Apple<int>();
The above code will work.
If I replace the same code with any other Generic Interface like IComparer<>
,IEnumerable<>
etc.. object creation like the above will not work and we have to declare it like
Apple<IEnumerable<int>> obj = new Apple<IEnumerable<int>>();
Why is it like that? Why is it the way which i declared for IComparable<>
is only working for it and not for any other interface?