ASP.NET泛型类型转换

        public List<T> RetrieveHtmlInput(HtmlForm form)
{
List<T> list = new List<T>();

foreach (Control ctrl in form.Controls)
{
if (ctrl is T)
{
T control = (T)Convert.ChangeType(ctrl, typeof(T));
list.Add(control);
}
}
return list;
}

T control = (T)Convert.ChangeType(ctrl, typeof(T));

posted @ 2012-01-01 13:48  大约  阅读(636)  评论(0编辑  收藏  举报