c# - 如何定义一个必须继承的类

标签 c# oop

如何定义一个必须继承的类?在 C# 中

最佳答案

您将类标记为 abstract (这是 VB.NET 必须继承 的 C# 模拟)。

这将确保它不能被直接实例化。

来自链接的 MSDN 文章:

The abstract modifier indicates that the thing being modified has a missing or incomplete implementation. The abstract modifier can be used with classes, methods, properties, indexers, and events. Use the abstract modifier in a class declaration to indicate that a class is intended only to be a base class of other classes. Members marked as abstract, or included in an abstract class, must be implemented by classes that derive from the abstract class.

(强调我的)

关于c# - 如何定义一个必须继承的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11172964/

相关文章:

c# - 使用 DotNetOpenAuth 将推文发布到 Twitter 帐户

c# - 映射类中未映射的属性 (Fluent NHibernate 1.1)

java - 具有相同方法名称的两个接口(interface) - 方法的实现

c# - c#中的Get和Set方法到底是如何使用和实现的

c++ - 从包装类公开内部类的公共(public)枚举

c# - 使用 Ajax 以 guid 作为键的 .NET MVC 字典绑定(bind)问题

c# - 使用表单元素与 UserControls 交互

javascript - 如何从javascript函数调用对象方法

javascript - 在类方法中删除元素后无法过滤数组

c# - 如何向 Windows Phone WebBrowser 添加多个 header ?