L
Lucvdv
VS2005: can someone explain why this code doesn't cause endless recursion?
It just returns False.
However, if you replace "Return TestProp" with "Return Me.TestProp", the
compiler warns for recursion (a warning, not an error), and it fails with a
stack overflow at runtime -- as expected.
Public Class Form1
Private Class TestClass
Public ReadOnly Property TestProp() As Boolean
Get
Return TestProp
End Get
End Property
End Class
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles MyBase.Load
Dim t As New TestClass
Debug.WriteLine(t.TestProp)
End Sub
End Class
It just returns False.
However, if you replace "Return TestProp" with "Return Me.TestProp", the
compiler warns for recursion (a warning, not an error), and it fails with a
stack overflow at runtime -- as expected.
Public Class Form1
Private Class TestClass
Public ReadOnly Property TestProp() As Boolean
Get
Return TestProp
End Get
End Property
End Class
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles MyBase.Load
Dim t As New TestClass
Debug.WriteLine(t.TestProp)
End Sub
End Class