Inheritance of base classes in Microsoft. NET <top>

Source: Internet
Author: User
Tags abstract inheritance
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 Creating Classes in. NET (English) can 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 Visual Basic 6.0 New Features Summary inheritance overview
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. Visual Basic programmers did not have this capability before Microsoft® Visual Basic®. NET was released. 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.

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.