Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Scala では、そのクラスを拡張できる唯一のクラスを同じクラスに配置する必要があるように、シールされた基本クラスまたは特性 (インターフェイス) を定義することができます。
これは、ライブラリをコーディングするときに便利なパターンです。.NET に同等のものはありますか?
これをシミュレートする唯一の方法は、抽象クラスにプライベート コンストラクターを持ち、ネストされたクラスとして実装を提供することです。
例
public abstract class Foo { private Foo(int k) {} public class Bar : Foo { public Bar() : base(10) {} } }