Using sealed to Prevent Inheritance

As powerful and useful as inheritance is, sometimes you will want to prevent it. For example, you might have a class that encapsulates the initialization sequence of some specialized hardware device, such as a medical monitor. In this case, you don’t want users of your class to be able to change the way the monitor is initialized, possibly setting the device incorrectly. Whatever the reason, in C# it is easy to prevent a class from being
inherited by using the keyword sealed.
 
To prevent a class from being inherited, precede its declaration with sealed. As you might expect, it is illegal to declare a class as both abstract and sealed because an abstract class is incomplete by itself and relies upon its derived classes to provide complete implementations.
 
Here is an example of a sealed class:

sealed class A
{
// ...
}
// The following class is illegal.
class B : A
{ // ERROR! Can't derive from class A
// ...
}

As the comments imply, it is illegal for B to inherit A because A is declared as sealed.
 
One other point: sealed can also be used on virtual methods to prevent further overrrides. For example, assume a base class called B and a derived class called D. A method declared virtual in B can be declared sealed by D. This would prevent any class that inherits D from overriding the method. This situation is illustrated by the following:

class B
{
    public virtual void MyMethod() { /* ... */ }
}
class D : B
{
    // This seals MyMethod() and prevents further overrides.
    sealed public override void MyMethod() { /* ... */ }
}
class X : D
{
    // Error! MyMethod() is sealed!
    public override void MyMethod() { /* ... */ }
}