Difference between revisions of "Sealed Modifier"

From Logic Wiki
Jump to: navigation, search
(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...")
 
(No difference)

Latest revision as of 10:45, 13 June 2017


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