---
title: "Can a sealed class be used as a base class?"  
description: "Can a sealed class be used as a base class?"  
author: "Ashutosh Kumar Verma"  
published: 2021-08-27  
updated: 2023-06-24  
canonical: https://www.mindstick.com/forum/156719/can-a-sealed-class-be-used-as-a-base-class  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Can a sealed class be used as a base class?

Can a [sealed class](https://www.mindstick.com/forum/33880/difference-between-abstract-class-and-sealed-class) be used as a [base class](https://www.mindstick.com/blog/116/base-class-initilization)?

\

## Replies

### Reply by Aryan Kumar

No, a sealed [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) cannot be used as a [base](https://www.mindstick.com/articles/12627/how-can-predictive-analytics-enhance-customer-base-and-experience) class. A sealed class is a class that cannot be inherited from. This means that you cannot create a subclass of a sealed class.

The `sealed` modifier is used to prevent derivation from a class. An error occurs if a sealed class is specified as the base class of another class.

Here is an example of a sealed class in C#:

C#

```plaintext
sealed class SealedClass {
  // Class members here.
}
```

In this example, the `SealedClass` class cannot be inherited from. If you try to create a subclass of the `SealedClass` class, you will get an error.

There are a few reasons why a sealed class might be used. One reason is to prevent the creation of subclasses that could potentially break the code. Another reason is to improve performance by preventing the compiler from having to generate code for potential subclasses.

If you need to create a class that cannot be inherited from, you can use the `sealed` modifier. This will prevent other developers from creating subclasses of your class, which can help to improve the safety and performance of your code.


---

Original Source: https://www.mindstick.com/forum/156719/can-a-sealed-class-be-used-as-a-base-class

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
