What Is Inheritance?
Inheritance is a very powerful form of code reuse. With inheritance, you write one class that contains some properties and methods. That class becomes the basis for other classes, and is known as the base class. Classes that then use this base class are known as derived classes. Most often, the derived classes extend the functionality of the base class.
Inheritance is the mechanism which allows class A to inherit properties of class B. We say “A inherits from B”. Thus, objects of class A have access to attributes and methods of class B without the need to redefine them. The following definition defines two terms with which we are able to refer to participating classes when they use inheritance.
Basic Inheritance Statement
Given two classes, one playing parent and the other child, all you need to do is add a single statement to indicate inheritance
The simplest inheritance relationship.
Public Class Parent
End Class
Public Class Child
Inherits Parent
End Class
-------------------
Another example:
If you want to add a property in a "UserControl"
Public Class MyUserControl
Inherits UserControl
Public Property MySetting() As Integer
Get
Return 1
End Get
End Property
End Class


0 comments:
Post a Comment