Lucas Silva Chaves
Lucas Silva Chaves

Reputation: 15

Is there a way to force all subclasses to be sealed?

I have an project requirement, which an specific abstract class should force all subclasses to be sealed C#, for instance:

public abstract class BaseProcess {
}

public sealed class HealthCheck : BaseProcess {
//Valid class
}

public class EtlSales : BaseProcess {
//Invalid, should emit a warning or a error when i compile
}

There's a data annotation or keyword, that force this configuration?

Upvotes: 0

Views: 169

Answers (1)

MarekK
MarekK

Reputation: 438

No. Unfortunately, C# does not have such an option.

Upvotes: 1

Related Questions