gpt4 book ai didi

.net - Vb.Net 属性语法

转载 作者:行者123 更新时间:2023-12-04 14:26:49 26 4
gpt4 key购买 nike

我在工作中问过我的同事,甚至试图在互联网上查找,但我一直无法得到答案。

之间有什么区别

Public Property Name As String


Public Property Name() As String

在属性名称后添加 () 有什么区别?

最佳答案

首先你可能会发现,Property 和 Methods 有很多相似之处。
从这个角度来看,Property 中的括号用于参数。如果一个属性没有参数,你可以省略它。以下是完整的属性声明语法:

[Default] [Modifiers] Property PropertyName[(ParameterList)] [As DataType]
[AccessLevel] Get
' Statements of the Get procedure.
' The following statement returns an expression as the property's value.
Return Expression
End Get
[AccessLevel] Set[(ByVal NewValue As DataType)]
' Statements of the Set procedure.
' The following statement assigns newvalue as the property's value.
LValue = NewValue
End Set
End Property

您可以在以下链接中找到有值(value)的提示:
What is the difference between a parameterized property and function in vb.net?

https://msdn.microsoft.com/en-us/library/e8ae41a4.aspx

关于.net - Vb.Net 属性语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29514247/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com