C# Sealed Inheritance with Programming Examples and Codes

Sealed-Inheritance
In this chapter you will learn

  • What is Sealed class?
  • Programming Examples and Codes

What is Sealed Class?

A sealed class cannot be a base class and it prevents derivation. Child class cannot inherit sealed class. A sealed class can be defined by putting sealed keyword before the class name.

  • Programming Example and Codes

     
    If you uncomment child class, it will raise compile time error.

     
    Output

    Hey, I am Sealed Class
    _

    Summary

    In this chapter you learned how to use Sealed class to hide base class from child. Sealed keyword locks the class so it is hidden from child class. In the next chapter you will learn Inheritance by programming examples.


    Leave a Reply

    Your email address will not be published. Required fields are marked *