In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to use code to achieve VB.NET inheritance, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
Using inheritance in VB.NET will bring great benefits to our programming. Now let's take a detailed look at a business example of VB.NET inheritance: every order has a line item, possibly a product line item and a service line item. There are some differences between the two line items. But when we implement the ProductLine and ServiceLine classes separately, we will find that they have a lot in common. If you write the code of these two classes separately, not only the programming efficiency is low, but also the program code is difficult to maintain, so the best way is to use some of the same code.
In order to use the same code, VB.NET inheritance plays a big role. Using VB.NET inheritance, we can create a LineItem class (parent class) that contains all the shared code. Then we create the ProductLine and ServiceLine subclasses, which are inherited by LineItem. So they can get all the shared code automatically. If the LineItem class is:
Public Class LineItem Private mintID As Integer Private mstrItem As String Private msngPrice As Single Private mintQuantity As Integer Public Property ID () As Integer Get Return mintID End Get Set mintID = value End Set End Property Public Property Item () As String Get Return mstrItem End Get Set mstrItem = Value End Set End Property Public Property Price () As Single Get Return msngPrice End Get Set msngPrice = Value End Set End Property Public Property Quantity () As Integer Get Return mintQuantity End Get Set mintQuantity = Value End Set End Property Public Function Amount () As Single Return mintQuantity * msngPrice End Function End Class
This class has all the common code as well as some basic data areas and methods for calculating the project price.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.