如何定义一个必须继承的类?在 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/