Resolve Type from Class Name in a Different Assembly

后端 未结 6 940
轮回少年
轮回少年 2020-11-27 17:32

I have a method where I need to resolve the Type of a class. This class exists in another assembly with the namespace similar to:

MyProject.Domain.Model
         


        
6条回答
  •  天涯浪人
    2020-11-27 17:53

    Can you use either of the standard ways?

    typeof( MyClass );
    
    MyClass c = new MyClass();
    c.GetType();
    

    If not, you will have to add information to the Type.GetType about the assembly.

提交回复
热议问题