Why can an abstract class not be sealed or static?
And I am also confused about the question Why declare static classes as sealed and abstract in C#?.
Why can an abstract class not be sealed or static?
And I am also confused about the question Why declare static classes as sealed and abstract in C#?.
Copyright © 2021 Jogjafile Inc.
staticclass cannot be markedsealedbecause it is madesealedby compiler by default.staticclass cannot be marked asabstract, because it would be pointless.abstractclass makes sense when you want all derived classes to implement same part of the logic. But becausestaticclass cannot be derived there is no way other class will implement these gaps.Both quotes from Static Classes and Static Class Members (C# Programming Guide).
C# specification is a little more detailed about that:
You can read what does it mean for class to be
sealedorabstract:Update
And a word about an article linked in the query you mentioned (Static Class Design). It's already stated in accepted answer from that question. If you read carefully you can see that:
.NET (so C# as well) do have built-in support for static classes, so you don't have (and even can't) to make your classes pseudo-static by marking it both
sealedandabstract.