Search code examples
.netc++-cliabstract-classsealed

Abstract Sealed Classes


Just a small question about c++/cli. Abstract classes have abstract methods to be implemented by derived classes, sealed classes dont allow inheritance.

So why we have some classes in .NET base class library defined as abstract sealed, and you can find plenty .. ??!


Solution

  • It is equivalent to "static class" in the C# language. The language that was used to write almost all of the BCL classes. All the methods must be static. Declaring it abstract and sealed prevents anybody from deriving from the class and creating an instance of it.

    The class methods are the exact equivalent of free functions in the C and C++ language. Something the CLR does not support.