Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use VB.NET Constructor function

Shulou Source: shulou.com Published: 2022-06-02 08:55:41 10月04日 Update

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!

Tags: Attributes that is different content articles programming that is values keys keywords interests variables at the same time multiple guys partners methods more knowledge independent variables Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MariaDB MySQL macOS Redmi