I can explain you the how can create a sealed class with the help of a program, in the following code, I create a sealed class named as Seal and use it from demo. Now here in this code if you make any attem to inherit the class which is sealed you will get an error.
using System;
class demo
Code:
{
static void Main(string[] args)
{
Seal s = new Seal();
int sum = s.Add(4, 5);
Console.WriteLine("sum = " + sum.ToString());
}
}
// Sealed class
sealed class Seal
{
public int Add(int a, int b)
{
return a + b;
}
}
Bookmarks