According to the online language link here , parentheses are required:
Property name ( [ parameterlist ] )
although, as we know, they can be omitted without changing the value if there are no parameters.
However, when referencing a property, there is an important difference. If you have an overloaded property and overload with links to parameters, without which, parameters are required when invoking an overload without parameters, otherwise it is resolved as a call to self, which returns nothing.
That is, in the following code, line 17 displays the warning “uninitialized”: Return MyProp.ToUpper() , and it throws a null reference exception at run time.
If you add brackets to two “recursive” calls, that is, MyProp() , this will work as expected.
Class Class1 Public Shared Sub Main() Dim c As New Class1 Console.WriteLine(c.MyProp(upper:=True)) End Sub Public Sub New() MyProp = "lower" End Sub Public ReadOnly Property MyProp As String Public ReadOnly Property MyProp(upper As Boolean) As String Get If upper Then Return MyProp.ToUpper() Else Return MyProp End If End Get End Property End Class
source share