The MyClass keyword
ensures that the Overridable method implemented in your base class is called, not the overridden
method in your derived class.
NotInheritable Classes
When you create a new class, you may design it with the express intent for it to serve as a base
class or to allow for specialization. VB offers the NotInheritable keyword for those occasions
when you want to prohibit a class from ever being derived from. At first, you might think that
you should rarely use the NotInheritable keyword. However, the contrary may be a better
practice, as inheritance can be tricky. For a class to serve as a good base class, you must design
it with that goal in mind. If not, you should mark it NotInheritable. Now you may be thinking,
???Shouldn??™t I leave it inheritable so that someone can possibly derive from it in the future, thus
retaining maximum flexibility???? The answer is usually no. A class that is meant to serve as a
base class should be designed with that in mind from the start.
MustInherit Classes
On the exact opposite end of the spectrum from NotInheritable classes are MustInherit classes.
Sometimes, you need to design a class whose only purpose is to serve as a base class. You mark
classes such as these with the MustInherit keyword.
Pages:
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98