/read-only-auto-property-backing-field-is-writeable.vb Secret
Last active Feb 3, 2019
Class Alarm | |
Private ReadOnly Code As Integer | |
ReadOnly Property Status As String = "Disarmed" | |
Sub New(code As Integer) | |
Me.Code = code | |
End Sub | |
Sub Arm() | |
' I'm motifying the value of this externally read-only property here. | |
_Status = "Armed" | |
End Sub | |
Function Disarm(code As Integer) As Boolean | |
If code = Me.Code Then | |
' And here. | |
_Status = "Disarmed" | |
Return True | |
Else | |
Return False | |
End If | |
End Function | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment