What is Sealed class?

Sealed class is a class that prevents the class from being inherited by other class.Sealed class can have Sealed Methods.Sealed method can't be override.To create a Sealed class we need to add Sealed modifier before class keywords.
eg.
sealed class MySealedClass
{
}
Sealed class can be a derived class but can't be a base class.A sealed class cannot be an abstract class. Because abstract class has to provide functionality and here we are restricting it to inherit. One of the best usage of sealed classes is when you have a class with static members.

Comments

Popular posts from this blog

Pagination of DataGrid in WPF using MVVM

Connect SQL Server Database to WPF Application and Perform CRUD Operations

Filter DataGrid and ListView in wpf using ICollectionView