.net实现多重继承问题(virtual)

时间:2023-03-10 00:27:02
.net实现多重继承问题(virtual)

C#中是没有类的多重继承这个概念.要使用多重继承必须要通过接口Interface来完成,

一。接口类

interface  getTable{ 
     DataTable Getdatatable(string str); 
  }

二。业务类

class getTableA:getTable{
    public virtual DataTable Getdatatable(string str){
     //具体业务逻辑略
   }
 }

三。定义基本类

class getMethod{
    public static getTable table(){
     return new getTableA();
   }
 }

四,具体实现

getMethod gm=new getMethod();
    getTable get=gm.table();
    get.Getdatatable("参数");