访问在运行时确定类型的通用实例的属性

时间:2018-11-23 11:47:50

标签: c# winforms generics reflection

我从这里来 链接:https://docs.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/how-to-examine-and-instantiate-generic-types-with-reflection
这是我的代码:

Type d1 = typeof(Dictionary<,>);
Type[] typeArgs = { typeof(string), typeof(string) };
Type constructed = d1.MakeGenericType(typeArgs);
object o = Activator.CreateInstance(constructed);


我的问题是:如何从对象“ o”访问方法和属性?

0 个答案:

没有答案