Can I use Activator.CreateInstance with an Interface?

前端 未结 6 1367
故里飘歌
故里飘歌 2021-01-04 00:21

I have an example:

        Assembly asm = Assembly.Load(\"ClassLibrary1\");
        Type ob = asm.GetType(\"ClassLibrary1.UserControl1\");
        UserContro         


        
6条回答
  •  北荒
    北荒 (楼主)
    2021-01-04 01:00

    What you want can be achieved using a IoC container like `NInject'. You can configure a container to return a concrete type when you've requested an interface.

提交回复
热议问题