开发者

Abstract type as parameter in method (.net, c#)

I have the following method which I use to fill a 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 tak开发者_运维问答e IEnumerables of type B?


protected void LoadDropDownList<T>(DropDownList ddl, IEnumerable<T> source) { 
    ...

See also.


protected void LoadDropDownList(DropDownList ddl, IEnumerable source) {
     ddl.DataSource = source;
     ddl.DataBind();
} 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜