可以用泛型 public <T> GetOrderInfo()
完全不一样的东西.你用一个方法返回.这本身就非常奇怪.
泛型接口了!
就返回父类类型啊,使用的时候再转
public interface IOrder
{
BaseOrder GetOrderInfo();
}
public abstract class BaseOrder:IOrder
{
public string Name { get; set; }
public abstract BaseOrder GetOrderInfo();
}
public class OrderA : BaseOrder
{
public string A { get; set; }
public override BaseOrder GetOrderInfo()
{
throw new NotImplementedException();
}
}
public class OrderB : BaseOrder
{
public string B { get; set; }
public override BaseOrder GetOrderInfo()
{
throw new NotImplementedException();
}
}
两个子类完全不一样也可以不用父类,直接接口
public interface IOrder
{
IOrder GetOrderInfo();
}
public class OrderA : IOrder
{
public string A { get; set; }
public IOrder GetOrderInfo()
{
throw new NotImplementedException();
}
}
public class OrderB : IOrder
{
public string B { get; set; }
IOrder IOrder.GetOrderInfo()
{
throw new NotImplementedException();
}
}