如何组合从一个类继承的多个子类的所有函数

时间:2013-01-10 13:31:21

标签: c# subclass

我需要使用从一个类继承的不同子类中嵌入的几个函数。例如,来自ListViewA的{​​{1}}和ListViewB。子类来自第三方软件和开源。有没有一种简单的方法来组合所有功能?

1 个答案:

答案 0 :(得分:0)

您可以尝试这样的事情:

foreach(ListView unknownListView in unknownObjectList)
{
    if (unknownListView is ListViewA )
    {
       var LWA = unknownListView as ListViewA;
       // ... do something with ListViewA 
    }
    if (unknownListView is ListViewB )
    {
       var LWB = unknownListView as ListViewB ;
       // ... do something with ListViewB 
    } 
}