Sealed Modifier

From Logic Wiki
Revision as of 10:45, 13 June 2017 by AliIybar (Talk | contribs) (Created page with "Category:OOP Category:CSharp Category:Extreme Programming Prevents derivation of classes or overriding of methods. <pre class="brush:csharp;"> public sealed clas...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Prevents derivation of classes or overriding of methods.

public sealed class Circle : Shape

you cannot derive a class from Circle

public class Circle : Shape
{
  public sealed override void Draw()
  {
  .....
  }
}

seal can be applied to only overriden methods.

Why ?

Sealed classes are slightly faster because of some run time optimizations.


Related Subjects : interface, Polymorphism, Abstract