Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the features of VB.NET object-oriented programming

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "what are the features of VB.NET object-oriented programming", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what are the features of VB.NET object-oriented programming" this article.

Class

In VB.NET object-oriented programming technology, class is the key point. To put it simply, a class is a data type that provides certain functions. The keyword Class is used to define a class in VB.NET. For example, the following short piece of code defines a class named Employee:

Class Employee End Class

Defining a class is as simple as that. Note that Microsoft recommends using Pascal naming rules when naming classes. According to this naming convention, it means that the * letters of the class name must be capitalized, and the * letters of the subsequent concurrent conjunctions are all capitalized, for example, GeneralManager, SmallDictionary, and StringUtil are all class names that conform to this rule.

Class member

A class has members like fields, properties, subroutines, and functions. For example, there is a subroutine named work in the following employee class:

The Employee class containing the Work method

Class Employee Public Sub Work ()'Do something here End Sub End Class

Subroutines and functions are called methods, and the naming of methods also follows the naming rules of the Pascal language.

Another category member is the domain. The naming rules for domains follow the camel rule, that is, all substrings except * * substrings are capitalized with * letters. Domain names such as salary and quarterlyBonus are compliant with the rules. The following code adds salary and quarterlyBonus fields to the Employee class:

Two domain Employee classes have been added

Class Employee Dim salary As Decimal = 4000 Dim yearlyBonus As Decimal = 4000 Public Sub PrintSalary () 'print the salary to the Console System.Console.Write (salary) End Sub End Class Module Module Public Sub Main () Dim anEmployee As Employee anEmployee = New Employee () anEmployee.PrintSalary () End Sub End Module

The Main function of the subroutine is provided in the Module1 module in the above code snippet, which is where the VB.NET program starts. To compile the source program, you must provide access to the Main Sub in one way or another.

These are all the contents of the article "what are the features of VB.NET object-oriented programming?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report