Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 .. ??!

like image 237
Ibrahim Najjar Avatar asked Sep 04 '10 21:09

Ibrahim Najjar


1 Answers

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.

like image 165
Hans Passant Avatar answered Sep 30 '22 14:09

Hans Passant