[Solved] C# – Cannot create an instance of the abstract class or interface [duplicate]


That’s the definition of an abstract class. You cannot create an instance of it, only a type derived from it.

Think of something like a fruit. You cannot have a fruit sitting on the table. It must be a certain type of fruit, such as an orange or an apple. In this case, fruit would be an abstract class, and can implement functionality and properties common to all fruit. Orange and Apple would derive from the Fruit class, and implement functionality and properties specific to that type of fruit.

Use the abstract keyword when it does not make sense to create an instance of your class, but you want to implement base functionality that can be shared across derived types. If you simply want to define a contract without any shared code, you’d use an interface.

5

solved C# – Cannot create an instance of the abstract class or interface [duplicate]