由于我无法对此帖子发表任何评论(仅发布答案),因此我将发布一个新问题。
我按照上述帖子中的说明进行操作,但代码会产生错误。
编码:
Type t = Type.GetType(className);
Type listType = typeof(List<>).MakeGenericType(t);
IList list = (IList)Activator.CreateInstance(listType);
错误:
使用泛型类型“System.Collections.Generic.IList”需要“1”类型参数
显然,我不能只说IList
没有任何类型,所以我想知道上述帖子的答案究竟是如何工作的。
提前致谢。