Senator Guerra Souty original series calendar,replica hublot blue steel peach pointer collocation of rolex replica Rome digital scale, track type minute replica watches scale shows that the classical model is swiss replica watches incomparable, wearing elegant dress highlights.
mr-ponna.com

 

YOU ARE HERE: HOME Questions How to prevent a class from being inherited



Prevent a class from being inherited - Sealed class in C#

View(s): 56524

How to prevent a class from being inherited?

Answer 1)

In order to prevent a class in C# from being inherited, the 
keyword sealed is used. Thus a sealed class may not serve as a base class of any other class. It is also obvious that a sealed class cannot be an abstract class. Code below...

//C# Example
sealed class ClassA
{
    public int x;
    public int y;
}

No class can inherit from ClassA defined above. Instances of ClassA may be created and its members may then be accessed, but nothing like the code below is possible...

class DerivedClass : ClassA { } // Error


  Asked in:  K.V.S.Infotech   Expertise Level:  Beginner
  Last updated on Thursday, 25 April 2013
4/5 stars (32 vote(s))

Register Login Ask Us Write to Us Help