【发布时间】:2009-09-10 16:31:54
【问题描述】:
我已经尝试了好几个小时了,这就是我所能做到的
var castItems = typeof(Enumerable).GetMethod("Cast")
.MakeGenericMethod(new Type[] { targetType })
.Invoke(null, new object[] { items });
这让我回来了
System.Linq.Enumerable+d__aa`1[MyObjectType]
而我需要(对于我的 ViewData)作为通用列表,即
System.Collections.Generic.List`1[MyObjectType]
任何指针都会很棒
【问题讨论】:
标签: c# generics reflection casting