The seal cannot be inherited. It is wrong to use the seal as the base class. Use the Sealed modifier in the class declaration to prevent inheritance. The Abstract modifier is not allowed to be used for sealing. The structure is implicitly sealed; therefore they cannot be inherited. Example // cs_sealed_keyword.cs // Sealed Classesusing System; Sealed Class Myclass {Public Int X; Public Int Y;
Class mainclass {public static void main () {myclass mc = new myclass (); mc.x = 110; mc.y = 150; console.writeLine ("x = {0}, y = {1}", MC. X, mc.y);}}
Output
X = 110, y = 150
In the previous example, if you try to use the following statement from the sealing class:
Class myderivedc: myclass {} // error
Error message will be received:
'Myderivedc' cannot inherit from timed class 'mybasec'.