2014-10-30 88 views
0

我正在使用UITableViewSource的子类来填充Xamarin ios中的UITableView中的数据。我想将List<T> someList作为参数传递给类的构造函数。虽然搜索我遇到了这Passing arguments to C# generic new() of templated type,但它并没有帮助我的原因。我怎么能达到这样的事情如何将泛型类型列表作为参数传递给xamarin-C#-ios中TableSource的构造函数?

public class TableSource : UITableViewSource 
{ 
    public TableSource(List<T> list) where T : new(){ 
    } 


} 

这是可以做到的吗?

回答

1

,让你通过一个通用的列表类型构造

public class TableSource<T> : UITableViewSource where T : new() 
{ 
    public TableSource(List<T> list) 
    { 

    } 


    public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) 
    { 
     throw new NotImplementedException(); 
    } 

    public override int RowsInSection(UITableView tableview, int section) 
    { 
     throw new NotImplementedException(); 
    } 
} 
相关问题