I am trying to find a better approach to set and get properties in a nested class that I create.
I have a Car class that has a nested ControlPanel class and wants the control panel properties to be accessible only to the Car and Control Panel class.
(i.e. not inside the assembly or namespace, and not inside the application, the class library will be used) ... I changed the classβs access properties to a friend, protected by a friend, private, public, but any combination does not match my expected results.
I want to change the properties in the Sub () Sub class, as shown below.
Any thoughts?
Public Class Car Dim cp As New ControlPanel Public Class ControlPanel Private _Speedometer As Integer = 0 Private _Odometer As Integer = 0 Public Property Speedometer() As Integer Get Return _Speedometer End Get Protected Set(ByVal value As Integer) _Speedometer = value End Set End Property Public Property Odometer() As Integer Get Return _Odometer End Get Protected Set(ByVal value As Integer) _Odometer = value End Set End Property End Class Public Sub Drive() cp.Odometer = 76323 co.Speedometer = 86 End Sub End Class
laughing chocolates
source share