Vb.Net Properties Syntax

First of all you may find it that Property has many similarities to Methods. from this prospective, parenthesis in Property used for parameters. if a Property has no parameter you can omit it. following is the full property declaration syntax:

[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

You may find valuable tips in following links: What is the difference between a parameterized property and function in vb.net? AND https://msdn.microsoft.com/en-us/library/e8ae41a4.aspx


You lookup these kind of details in the VB.NET Language Specification. It is a pretty formal document but nevertheless quite readable. Chapter 9.7 contains all the details about the Property keyword syntax. You'll for example see:

PropertySignature  ::=
    Property  Identifier  [  OpenParenthesis  [  ParameterList  ]  CloseParenthesis  ]
        [  As  [  Attributes  ]  TypeName  ]

The [] brackets indicate optional parts of the syntax. So you can easily see that you don't have to use () if the property doesn't take any parameters. In other words, when it is not an indexed property.

So there is no difference.

Tags:

.Net

Vb.Net