While creating a generic interface, I can define constraint that the generic parameter should inherit from a particular interface(IBase).
interface IGeneric<T> where T : IBase
{
List<T> property{get; set;}
}
Is there any use of this? As I can just substitute this with the following interface, which will serve the same purpose and is much simpler.
interface IGeneric
{
List<IBase> property{get; set;}
}
It seems to me that we do not need generic at all in this scenario, as we already know that T will be IBase. And the IBase property can already acomodate all its derived types. So what is the use of generic with a specific interface constraint?