如何在C#中派生两个抽象类 [英] How to derive two abstract classes in C#
本文介绍了如何在C#中派生两个抽象类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有应用结构-
public abstract class a
{
}
//defined in a.dll
public abstract class b
{
}
//defined in b.dll
//Above 2 DLL reference added in main project where I want to derive both of this abstract classee like
public abstract class proj : a, b
{
}
我能够推导其中的任何一个,而不能同时推导两者.因此,请指导我有关我遗失的东西或我做的错误编码.
I am able to derive any one of it only not both. So pls guide me on missing things or wrong coding I had done.
推荐答案
您不能使用C#多重继承.但是,您可以使用接口.
You can't multiple inherit using C#. You can however achieve this by using an interface.
public interface Ia
{
}
public interface Ib
{
}
public abstract class MainProject : Ia, Ib
{
}
C#接口仅允许方法,属性,事件和索引器的签名.您必须在proj
(MainProgram)类中定义这些实现.
C# interfaces only allow signatures of methods, properties, events and indexers. You will have to define the implementation of these in the proj
(MainProgram) class.
这篇关于如何在C#中派生两个抽象类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文