Wednesday, 10 September 2014

Sealed Class with example

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.


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);



Post a Comment