---
title: "What is the sealed class?"  
description: "What is the sealed class?"  
author: "Om ji mishra"  
published: 2019-10-28  
updated: 2019-10-28  
canonical: https://www.mindstick.com/forum/135442/what-is-the-sealed-class  
category: "c#"  
tags: ["c#", "programming language"]  
reading_time: 1 minute  

---

# What is the sealed class?

What is the [sealed class](https://www.mindstick.com/forum/33880/difference-between-abstract-class-and-sealed-class)?

## Replies

### Reply by Om ji mishra

When we create a sealed [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) 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.

```
Code:-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;
    }
}
```

```
Output:- Total = 9
```


---

Original Source: https://www.mindstick.com/forum/135442/what-is-the-sealed-class

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
