Basic class inheritance in Microsoft. NET & lt; above & gt;

Source: Internet
Author: User

Basic class inheritance in Microsoft. NET
Upgrade to Microsoft. NET
Paul D. Sheriff
PDSA, Inc.
December 2001
Abstract: This article introduces inheritance, explains how to inherit base classes, and introduces implementation inheritance and interface inheritance in Microsoft. NET.
Overview of Object Inheritance learn how to inherit a base class understand interface inheritance understand the prerequisites for implementing inheritance
To thoroughly understand the content of this article, you must meet the following conditions: Understanding the basic encoding, understanding the class and its working principle, or reading the Creating Classes in. NET (English) article to use Microsoft®Visual Basic®. NET directory inheritance overview inheritance base class build example form create subclass add other features MyBase keywords abstract class select the inheritance type to use overview of new features inherited since Visual Basic 6.0
One of the main functions of Object-Oriented Programming (OOP) is "inheritance ". Inheritance refers to the ability to use all the functions of an existing class and extend these functions without re-writing the original class. In Microsoft®Visual Basic®Before. NET was released, Visual Basic programmers did not have this capability. In Visual Basic. NET, you can inherit the classes in the Microsoft. NET Framework or the classes you have created. In this article, we will learn how to use inheritance and how inheritance greatly shortens programming time. Simple Example
Among the many classes you have created, you will find that you often need the same attributes and methods as the attributes and methods in the previously created class. For example, if a base class named "Person" contains the LastName and FirstName attributes and the Print method, you will find that you also need these attributes and methods for the Employee class. You may also need other attributes, such as EmployeeID and Salary. If you inherit from the Person class (base class), you can add these attributes to the new Employee class and still access all attributes in the Person class. Inheritance refers to the ability of a class to define itself as all attributes and methods of a specific class, and then expand the definition of the base class by adding other attributes and methods. Inheritance term
Before going into this topic, Let's define several terms first. The new classes created by inheritance are called "subclasses", and the inherited classes are called "base classes", "parent classes", or "superclasses ". In some OOP languages, a subclass can inherit multiple base classes. That is to say, if there is a Person class and a Car class, the Driver class can inherit all the attributes and methods of the two classes. In. NET, only a single inheritance is allowed. Therefore, each subclass can have only one base class.
. NET supports three types of inheritance: Implementation inheritance, interface inheritance, and visual inheritance. Implementation Inheritance refers to the ability to use the attributes and methods of the base class without additional encoding; interface inheritance refers to the ability to only use the names of attributes and methods, but the subclass must provide implementation; visual Inheritance refers to the ability of sub-forms (classes) to use the appearance of base Forms (classes) and implement code.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.