Consider that classes
public class Category { }
public class Product { }
public interface IService<T> { }
public class ServiceBase<T> : IService<T> { }
public class CategoryService : ServiceBase<Category> { }
public class ProductService : ServiceBase<Product>, IService<Product> { }
Is inheritances of ProductService redundant? Just ServiceBase<Product> is enough?
I just made tests like this
static void Main(string[] args) {
Console.WriteLine("CategoryService interfaces:");
foreach(var item in typeof(CategoryService).GetInterfaces()) {
Console.WriteLine(item.Name);
}
Console.WriteLine("ProductService interfaces:");
foreach(var item in typeof(ProductService).GetInterfaces()) {
Console.WriteLine(item.Name);
}
Console.ReadKey();
}
output
CategoryService interfaces:
IService`1
ProductService interfaces:
IService`1
Yes it's redundant.
You can remove it and ProductService will still implement IService<Product>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With