In this programming tutorial let's understand what is a sealed class by going through the below topic on sealed class:
- What is sealed class
- How to define a sealed class
- Sealed classes .NET framework
- Singleton design pattern & sealed class
What is sealed class
Inheritance is one of the building block of the OOPS. However sometimes, allowing a class to be inherited doesn't make sense. In such circumstances, we can make the class cannot be inherited. C# .NET, has exposed a keyword, "sealed", to make a class cannot be inherited. So in essence, the class which cannot be inherited are called Sealed class.
How to define a sealed class
public sealed class BaseClass
{
}
As you can see above in the above C# code sample, the keyword "sealed" is used to make the BaseClass as sealed class.
{
}
Sealed class .NET framework
string (System.String) is a sealed class.
No comments:
Post a Comment