我问过我的同事,甚至试图在互联网上查找这个问题,但我一直无法得到答案。
有什么区别
Public Property Name As String
and
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
您可以在以下链接中找到有价值的提示:vb.net 中参数化属性和函数有什么区别? https://stackoverflow.com/questions/9728321/what-is-the-difference-between-a-parameterized-property-and-function-in-vb-net
AND
https://msdn.microsoft.com/en-us/library/e8ae41a4.aspx https://msdn.microsoft.com/en-us/library/e8ae41a4.aspx
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)