The questions is pretty straight forward, and can't find the answer in any of my readying. How do shared members from a base class react when a derived object is instantiated when the base class is not instantiated in VB.Net? Does the shared constructor get called at the base level? I am trying to figure out if a base class initializes a set of shared members in the shared new()
method defined at the base class will be accesible by the instantiated derired class, given the proper accessors, if the base class is not instantiated?
Public Class Car
Protected Shared _carCount as Integer
Shared Sub New()
_carCount = 0
End Sub
Shared Public Function GetCount() as integer
return _carCount
End Sub
End Class
Public Class Sedan
Inherits Car
Shared Sub New()
_carCount = _carCount + 1
End Sub
End Sub
Sub Main()
Dim someSedan as New Sedan
System.Console.Writeline(someSedan.GetCount())
End Sub
This code is not checked, but it should give enough of an idea what I am talking about.