---
title: "What are sealed classes in C#?"  
description: "What are sealed classes in C#?"  
author: "Shikhar Arora"  
published: 2019-12-06  
updated: 2023-04-11  
canonical: https://answers.mindstick.com/qa/92489/what-are-sealed-classes-in-c-sharp  
category: "programming language"  
tags: ["c#", ".net programming"]  
reading_time: 2 minutes  

---

# What are sealed classes in C#?

What are [sealed classes](https://www.mindstick.com/interview/23357/what-are-sealed-classes-in-c-sharp) in C#

## Answers

### Answer by Mark John

A sealed class in C# is a special type of class that prevents other classes from [inheriting](https://www.mindstick.com/articles/13095/inheritance-and-its-types) from it. When a class is declared as sealed, it means that it is the final implementation of that class and no other class can inherit from it. This is different from regular classes, which can be inherited by other classes to extend their functionality.

Sealed classes are typically used when a class needs to provide a complete implementation of a certain functionality or behavior and it is not designed to be modified or extended by other classes. This is because sealed classes provide a level of [security and stability](https://www.mindstick.com/blog/301788/what-is-cybersecurity-everything-you-need-to-know) by preventing unwanted changes to their implementation.

![What are sealed classes in C#?](https://answers.mindstick.com/questionanswer/d0e26365-46fe-485f-a77d-7ec3e7fd1eba/images/98cff19b-8fa6-4bbc-8eef-e4aabf68ef04.png)

Sealed classes also provide performance benefits by allowing the compiler to optimize the code more efficiently. Since a sealed class cannot be inherited, the compiler can make certain assumptions about the class's behavior, which can lead to faster and more [efficient code execution](https://www.mindstick.com/blog/301872/ai-assisted-coding-what-software-developers-need-to-know-about).

To declare a class as sealed in C#, you simply add the sealed keyword to the class definition. Once a class is declared as sealed, it cannot be inherited by any other class.

In summary, sealed [classes in C#](https://www.mindstick.com/forum/160401/describe-the-role-of-delegates-and-events-in-working-with-generic-methods-and-classes-in-c-sharp) are a useful tool for creating stable and efficient code by preventing unwanted changes to the class's implementation and allowing the compiler to optimize the code more efficiently.


---

Original Source: https://answers.mindstick.com/qa/92489/what-are-sealed-classes-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
