Why do I get an error instantiating an interface?

后端 未结 6 1067
生来不讨喜
生来不讨喜 2020-12-08 06:22

I have a class and an interface, and when I try to instantiate the interface, I get an error:

Cannot create an instance of the abstract class or inter

6条回答
  •  独厮守ぢ
    2020-12-08 07:08

    It is what it says, you just cannot instantiate an abstract class. You need to implement it first, then instantiate that class.

    IUser user = new User();
    

提交回复
热议问题