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));