[英]Abstract type as parameter in method (.net, c#)
I have the following method which I use to fill a DropDownList-Control. 我有以下方法用于填充DropDownList-Control。
protected void LoadDropDownList(DropDownList ddl, IEnumerable<A> source)
{
ddl.DataSource = source;
ddl.DataBind();
}
My question is, can I make the method more abstract so that it can also take IEnumerables of type B? 我的问题是,我可以使该方法更抽象,以便它也可以采用类型B的IEnumerables吗?
protected void LoadDropDownList(DropDownList ddl, IEnumerable source) {
ddl.DataSource = source;
ddl.DataBind();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.