Alex Rivera | Logout

get the Type for a object declared dynamic

Asked 2011-09-09T13:41:27.003
32

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

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

Except that in the above, GetType() returns the type of the wrapper for dynamic objects not the type of the wrapped object. Thanks!

Edit
Report

1 Answer

2

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

object tmp = Activator.CreateInstance(assembly, nmspace + "." + typeName);
Type unknown = tmp.GetType();
answered 2011-09-09T14:07:31.900

Your Answer