Dynamically loading classes (with custom behavior) from different assemblies?

后端 未结 6 997
遥遥无期
遥遥无期 2021-02-10 14:36

We are building an app for few customers, each has its own requirements along with the similar ones. We also want to keep all the code in the same app, not branch it, and the IF

6条回答
  •  遇见更好的自我
    2021-02-10 15:23

    maybe this example will be helpful

    public MyInterface GetNewType() { 
           Type type = Type.GetType( "MyClass", true ); 
           object newInstance = Activator.CreateInstance( type ); 
           return newInstance as MyInterface; 
        } 
    

提交回复
热议问题