无法解析作为类型的符号

use*_*249 1 .net c# reflection

Type myType = Type.GetType(nameOfTypeString);
DoSomething(typeof(myType));

// signature of DoSomething
DoSomething(Type myType)
Run Code Online (Sandbox Code Playgroud)

抱怨它无法解析myType.

Jus*_*ner 5

typeof操作返回的实例Type类.

在这种情况下,您已经拥有了一个实例Type.您应该能够简单地将其传递给方法:

DoSomething(myType);
Run Code Online (Sandbox Code Playgroud)