Abstract Sealed Classes

痞子三分冷 提交于 2019-12-07 04:15:39

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/3644004/abstract-sealed-classes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!