3
Reply

Which class that cannot be inherited

Pavan R Bhupalam

Pavan R Bhupalam

11y
2.8k
1
Reply

    Sealed class

    Sealed classes cannot be inherited. Class that are marked with the sealed (C#) or NotInheritable (VB.NET) keywords cannot be inherited from. This is done at the definition of the classes.The most commonly used sealed class is System.String. Abstract and Sealed Classes and Class Members (C# Programming Guide): public sealed class D { // Class members here. }A sealed class cannot be used as a base class. For this reason, it cannot also be an abstract class. Sealed classes prevent derivation. Because they can never be used as a base class, some run-time optimizations can make calling sealed class members slightly faster. MustInherit and NotInheritable Classes: NotInheritable Class A End Class Class B ' Error, a class cannot derive from a NotInheritable class. Inherits A End ClassA NotInheritable class is a class from which another class cannot be derived. NotInheritable classes are primarily used to prevent unintended derivation. In this example, class B is in error because it attempts to derive from the NotInheritable class A. A class can not be marked both MustInherit and NotInheritable.

    Sealed Class