suppose that i have a base class
class Document
{
//some properties
}
and two derived classes:
public class Order:Document
{
//some properties
}
public class Request:Document
{
//some properties
}
now i want make a layered application that have a service layer. also i want have a base service layer interface such as:
public interface IBaseService<T> where T:Document
{
IList<T> GetAll();
}
that my layer service classes implement it:
public SaleService:IBaseService<Document>;
So i must define IList<Document> GetAll() to implement base service, but i want my SaleService has IList<Order> GetAll() and IList<Request> GetAll() methods, instead IList<Document> GetAll().
how can i do it?
IList<T>method inIBaseService<T>interface.GetAll()methods on the same class, with different return types. You can't do that in C#. Please try to clarify your question.public SaleService:IBaseService<Order> ...;, otherwise the<T>parameter is superfluous.