What is the sealed class?

Om ji mishra

Total Post:17


Posted by  Om ji mishra
 1085  View(s)
Rate this:

What is the sealed class?        

  1. Re: What is the sealed class?

    When we create a sealed class then we cannot inherit that class with any derived class. It is created when we want to restrict the class from being inherited. if we use a shield class with any derived class then the compiler will throw an error. We can use the property of a sealed class in any other class by creating an object.

    using System
    class Class1
    static void Main(string[] args)
        SealedClass sealedCls = new SealedClass();
        int total = sealedCls.Add(4, 5);
       Console.WriteLine("Total = " + total.ToString());
    sealed class SealedClass
      public int Add(int x, int y)
          return x + y;
    Total = 9


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.