Blocking inheritance is the opposite of requiring it. Certain classes block inheritance to prevent derived classes from overriding virtual methods that come from interfaces or from other base classes. For example the string class in .NET blocks inheritance. One reason may be that the string class overrides functions that determine things like equality. The class may make certain assumptions as to how these methods work. If the string class didn't block inheritance, any developer would be able to create a subclass and override how equality is determined and potentially invalidate some of the assumptions made in the original string class. To block inheritance:
|