I come from a Java background so this a puzzle to me. I'm wondering why this happens in .net. Why do I have use the class name in order to get the variables value in .net?
Code:
Public Class Form1 Public varPub as String = "PUBLIC" Private Sub Main varPub = "PUBLIC" subClass = New SecondClass() subClass.IsIT() End Sub End Class Public Class SecondClass Inherits Form1 Public Sub IsIT() MessageBox.Show(varPub) 'Shows blank MessageBox.Show(Form1.varPub) 'shows value End Sub End Class
Comment