“无法创建抽象类或接口的实例”。 C#错误消息 [英] "Cannot create an instance of the abstract class or interface" C# error message

查看:853
本文介绍了“无法创建抽象类或接口的实例”。 C#错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I changed my base class to abstract for a project and now I'm receiving the following error:


无法创建抽象类或接口的实例

Cannot create an instance of the abstract class or interface

我收到错误消息是因为命名了新的抽象类的实例是不允许的?

Am I receiving the error because naming a new instance of an abstract class is not allowed?

newPlane = new Airplane_Abstract(name, position);


推荐答案

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

You can't create an instance of an abstract class. Think of it as an interface that may contain some implementation logic as well. What would you expect to happen if you called an abstract instance method with no definition?

这篇关于“无法创建抽象类或接口的实例”。 C#错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆