get the Type for a object declared dynamic

后端 未结 2 2015
太阳男子
太阳男子 2020-12-01 10:57

I would like to get the Type for an dynamic object, something like:

dynamic tmp = Activator.CreateInstance(assembly, nmspace + \".\" + typeName);
Type unknow         


        
2条回答
  •  庸人自扰
    2020-12-01 11:03

    If you can use Activator.CreateInstance, you can directly use:

    object tmp = Activator.CreateInstance(assembly, nmspace + "." + typeName);
    Type unknown = tmp.GetType();
    

提交回复
热议问题