- object obj = new object();
-
-
- object o = Activator.CreateInstance(obj.GetType());
-
-
- Type generic = typeof(List<>);
- Type[] typeArgs1 = { obj.GetType() };
- generic=generic.MakeGenericType(typeArgs1);
- var list=Activator.CreateInstance (generic) as IList;
-
-
- generic = typeof(Dictionary<,>);
- Type[] typeArgs2 = { typeof(string), obj.GetType() };
- generic = generic.MakeGenericType(typeArgs2);
- var dic = Activator.CreateInstance(generic) as IDictionary;
本文转自 virusswb 51CTO博客,原文链接:http://blog.51cto.com/virusswb/461962如需转载请自行联系原作者