0

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

4

1 回答 1

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 
    } 
}
于 2013-01-10T13:37:01.097 回答