ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

What is a sealed class used for in c#?

user-image
تم إضافة السؤال من قبل مستخدم محذوف‎
تاريخ النشر: 2016/04/05
Syed Abbas
من قبل 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.

 

 

المزيد من الأسئلة المماثلة