In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about the specific operation skills of adding methods to the VB.NET class, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
VB.NET is an object-oriented programming language. If we want to skillfully master the application of this language, we need to accumulate experience from practice. The VB.NET class addition methods we introduce below are those public Sub or Function procedures that the user declares in the class.
For example, the following code adds a Withdrawal method to an Account, and the user can add this public function procedure to the class module:
Public Function WithDrawal
(Byval Amount As Currency,_
Byval TransactionCode As
Byte) As Double
'(Code to perform the
Withdrawal and return the
'new balance,or to raise
An Overdraft error.)
End Function
If the class Account has the Balance attribute, the user does not have to return the value of balance, because the user can easily access the balance property after calling the WithDrawal function, so the user can replace this function with a public procedure.
Parsing the implementation of VB.NET object variable declaration
Operation skills related to VB.NET String data types
Introduction to the implementation method of VB.NET custom type
Simple Analysis of VB.NET Sub process
Analysis of the related functions of VB.NET New keywords
Note: if you find that after setting WithDrawal as a procedure when adding methods to the VB.NET class, you have to access the balance attribute value after each call to the WithDrawal procedure, then it will be more efficient to set WithDrawal to the value that the function returns balance. This is because for the properties of a class, getting the value of a property each time is also calling a common function PropertyGet and accessing some public variables, regardless of whether the PropertyGet function is explicitly declared or implicitly declared.
In the class module, by defining properties and methods, it constitutes an external interface of the class, just as the data encapsulation of the class, if the user declares a procedure as private, then it cannot be part of the interface. This means that users can change the operation of the entire program by changing some private internal processes in the class without changing the code that uses the class.
More importantly, users can also change some functions of the entire program by changing the public Sub or Function procedure as a method to add a VB.NET class, without involving the code that uses the class, just as the parameters of the procedure and the return type of the function cannot be changed, and externally, the user cannot change the interface of a class.
Hiding the specific situation of a class outside the interface of the class can be regarded as a manifestation of the encapsulation of the class, which allows the user to improve the performance of a method of the class without changing the code of the class. or completely change the running function of the method of a class.
After reading the above, do you have any further understanding of the specific operation skills of adding methods to the VB.NET class? If you want to know more knowledge or related content, 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.