Sealed Class:
A sealed class is a class which cannot be inherited. A sealed class cannot be a base class. The modifier abstract cannot be applied to a sealed class. By default, struct (structure) is sealed. It is the last class in hierarchy. To access the members of a sealed class, you must create objects of that class.
Sealed Class is denoted by the keyword sealed.
Example:
sealed class mySealedClass
{
int a;
int b;
}
class mainClass
{
public static
void Main()
{
mySealedClass obj = new mySealedClass();
obj.a = 5;
obj.b = 7;
Console.WriteLine("a = {0}, b = {1}", obj.a, obj.b);
}
}
0 comments:
Post a Comment