Can I use Activator.CreateInstance with an Interface?

前端 未结 6 1365
故里飘歌
故里飘歌 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 00:56

    Interface is an interface. It's a template. Why would you want to instantiate an interface? Implement the interface and instantiate that class. You can't instantiate an interface, it doesn't really make sense.

提交回复
热议问题