---
title: "What is sealed class in C#?"  
description: "What is sealed class in C#?"  
author: "Rahul Roi"  
published: 2019-09-09  
updated: 2019-09-09  
canonical: https://www.mindstick.com/forum/95344/what-is-sealed-class-in-c-sharp  
category: "c#"  
tags: ["c#", "oops"]  
reading_time: 2 minutes  

---

# What is sealed class in C#?

Give an example of using a [Sealed class](https://www.mindstick.com/forum/33880/difference-between-abstract-class-and-sealed-class) in C#.

## Replies

### Reply by Anonymous User

Below is the sample code of **sealed [class in C#](https://www.mindstick.com/forum/160399/how-to-create-a-custom-generic-class-in-c-sharp-provide-an-example)** :-

```
Example (1).

class X {}
sealed class Y : X {}
//Sealed methods –
class A
{
 protected virtual void First() { }
 protected virtual void Second() { }
}
class B : A
{
 sealed protected override void First() {}
 protected override void Second() { }
}
```

Note :- If any class inherits from class “B” then method – “First” will not be overridable as this method is sealed in class B.

```
Example (2).

// C# code to define
// a Sealed Class
using System;
// Sealed class
sealed class SealedClass {
    // Calling Function
    public int Add(int a, int b)
    {         return a + b;     } }

class Program {
    // Main Method
    static void Main(string[] args)
    {
        // Creating an object of Sealed Class
        SealedClass slc = new SealedClass();
        // Performing Addition operation
        int total = slc.Add(6, 4);
        Console.WriteLine("Total = " + total.ToString());     } }
```


---

Original Source: https://www.mindstick.com/forum/95344/what-is-sealed-class-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
