Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What is sealed class in c#?

user-image
Question added by Mohannad Bakbouk , Full Stack Web Developer , Almohtaseb
Date Posted: 2016/10/20
Pathan Zarrar Khadar Khan
by Pathan Zarrar Khadar Khan , Windows System Administrator , Dyce Tech Pvt Ltd

Sealed classes are used to restrict the inheritance feature of object oriented programming. Once a class is defined as a sealed class, the class cannot be inherited. In C#, the sealed modifier is used to define a class as sealed

You can not inherit class form the seal class. If you know the Java then it is similar to "final class" in Java. Here is MDSN page for few examples. 

https://msdn.microsoft.com/en-us/library/88c54tsw.aspx

Shahid Riaz Qureshi
by Shahid Riaz Qureshi , Senior Software Engineer , Royal IHC

A class that cannot be inherited in order to protect it's functionality.

Muhammad Ali
by Muhammad Ali , Senior Software Engineer , TPS Pakistan

A sealed class is the one which can not be inherited by other classes.A class can be declared as sealed by using the keyword "sealed" in class declaration.

Bineesh VP
by Bineesh VP , Software Developer , Unknown

Seales class is the feature of OOP . A class cannot be inherited from outside scope.

sealed class is used to the define inheritance level of a class.sealed classes are used to restrict the inheritance feature in object oriented .it can be derived but it is not a base class .once a class is defined as a sealed class it cannot be inherited.

Javad Ahmadzadeh
by Javad Ahmadzadeh , Web Developer – Android Developer , Donyay-e Pardazesh-e Abri

When we define a class with "sealed" modifier, we cannot inherit it. It's equivalent to NonInheritable on VB.NET

Shahid Malik
by Shahid Malik , Senior Software Engineer , Capgemini India

Class is declared as Sealed in order to prevent it from being Inherited.

Nauman Zafar
by Nauman Zafar , Senior Software Engineer , Polymer DLP

C# offers a sealed keyword for protecting classes to be inherited. Why use Sealed classes ? You are implementing some security features using that particular class and don't want the object to be manipulated. Secondly, sealed keyword is an indication to Common Language Runtime (CLR) that there are no sub-classes to look down which further increases overall performance if properly used.

Ziauddin Zia
by Ziauddin Zia , Software Engineer , Asia Poultry Feeds (Pvt) Ltd

Sealed, as is name indicates lock the class from inheritance.

So simple is that sealed classes cannot be inherited.

Ubaid sayeed Mohd abdul sayeed
by Ubaid sayeed Mohd abdul sayeed , Senior Programmer , Moksha solutions

restrict the inheritance feature of object oriented programming.