c# - 如何强制单继承?

标签 c# .net inheritance

我有两个类:

public class A
{
}

public sealed class B : A
{
}

而且我希望只有我的 B 类(在 A 的同一程序集中定义)可以继承 A
我该怎么办?

最佳答案

And I want that only my B class (defined in the same assembly of A) can inherits A. How can I do?

那么根本不需要继承..

public sealed class B
{
  //includes all methods of A and B
}

关于c# - 如何强制单继承?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13086405/

相关文章:

c# - 使用 JSON.NET 反序列化值为字段名称的 JSON

.net - F#函数匹配

java - 继承破坏了封装

c# - Windows Phone 8 上的 VariableSizedWrapGrid

c# - Xamarin 哪里是 Id 对象

c# - 将对象标记为可序列化会产生开销吗?

language-agnostic - 更喜欢组合而不是继承?

inheritance - EclipseLink MOXy : Superclass fields are not set when unmarshaling

c# - 反序列化 JSON 颜色十六进制,不带引号

c# - 正则表达式在第一个空格后获取所有内容