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

How to use VB.NET Constructor function

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

Share

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

This article mainly introduces how to use the VB.NET Constructor function, the article is very detailed, has a certain reference value, interested friends must read it!

Object Oriented programming

That is, add Properties to the Class. The values of some attributes are limited to reading and cannot be written, while others can be written but cannot be read, but generally both.

Public Class ClassName

Private VeriableName As DataType

[Public | Private | Protected] [Property]

PropertyName () As DataType

Get

'/ /.

Return VeriableName

End Get

Set (ByVal Value As DataType)

VeriableName = Value

End Set

End Property

End Class

Attributes that can only read the number of values:

Public Class ClassName

Private VeriableName As DataType

[Public | Private | Protected] [ReadOnly]

[Property] PropertyName () As DataType

Get

'/ /.

Return VeriableName

End Get

End Property

End Class

Attributes that are limited to the number of values:

Public Class ClassName

Private VeriableName As DataType

[Public | Private | Protected] [WriteOnly]

[Property] PropertyName () As DataType

Set (ByVal Value As DataType)

VeriableName = Value

End Set

End Property

End Class

How to declare and execute certain functions at the same time of Instantiate Class, such as creating a new SqlConnection Object or declaring variables, etc. To achieve this, we use Class's VB.NET Constructor function. Here is the syntax for adding VB.NET Constructor functions to Class.

Public Class CalssName [Public] [Sub] New ()'/ /... End Sub End Class

Because this is Object Oriented programming, you can also build VB.NET Constructor functions with different arguments. But here is a little different from writing an Overloads method (Method), that is, there is no need to use the Overloads keyword to indicate that the function is an Overloads function.

Public Class CalssName [Public] [Sub] New (Byval Arguement As DataType)'/ /. End Sub End Class above is all the contents of this article entitled "how to use VB.NET Constructor functions". Thank you for reading! Hope to share the content to help you, more related 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