Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

What is a sealed class used for in c#?

user-image
Question ajoutée par Utilisateur supprimé
Date de publication: 2016/04/05
Syed Abbas
par Syed Abbas , It Analyst , Tata consultancy services

In simple terms, Sealed class is used in c# to avoid other classes to inherit your class. Some points to remember when working with Sealed Classes

  • Sealed class cannot be a base class
  • Sealed class can be a derived class
  • Sealed class cannot be an abstract class because it has to implement the abstract methods in the derived class which we are restricting here.

 

In addition to your question you can even seal your methods in a non-sealed class. This is used to define the overriding level of a virtual method.Sealed keyword in methods is always used with Override keyword.

 

Hope this helps.

 

 

More Questions Like This