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

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

问题描述

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

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

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

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天全站免登陆