c# - "Cannot create an instance of the abstract class or interface"C#错误信息

标签 c# abstract-class

我将项目的基类更改为 abstract,现在我收到以下错误:

Cannot create an instance of the abstract class or interface

我是否收到错误,因为不允许命名 abstract 类的新实例?

newPlane = new Airplane_Abstract(name, position);

最佳答案

您不能创建抽象类的实例。将其视为可能包含一些实现逻辑的接口(interface)。如果你调用一个没有定义的抽象实例方法,你会期望发生什么?

关于c# - "Cannot create an instance of the abstract class or interface"C#错误信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4949242/

相关文章:

c# - 使用 StringFormat 隐藏零值

c# - 静态内部类是否有性能成本?

c# - 配置系统初始化失败

C# 按钮不重新定位自己

c# - 在 C# 中将参数值从一个函数传递到另一个函数

c# - 抽象类设计 : Why not define public constructores?

java - 为什么 HTTPServlet 是一个抽象类?任何功能原因?

java - 在类中保存密码的最理想方式 - Java

java - 我可以避免在子类中实现参数化构造函数吗

C++ 多重继承 : Using base class A's implementation for abstract method of base class B