D
Don
If you expose an object as a property in a VB.NET class, like so:
public class MyClass
private obj as NestedClass
Public Readonly Property NestedObj as OtherClass
Get
return obj
End Get
End Property
End Class
You can't modify the object directly, but you can still modify members of
the readonly property(!):
Dim myobj as MyClass
myobj.NestedObj = New NestedClass ' Doesn't work
myobj.NestedObj.Whatever = "hello" ' Works! And the changes stick!
Is there anyway to prevent this?
- Don
public class MyClass
private obj as NestedClass
Public Readonly Property NestedObj as OtherClass
Get
return obj
End Get
End Property
End Class
You can't modify the object directly, but you can still modify members of
the readonly property(!):
Dim myobj as MyClass
myobj.NestedObj = New NestedClass ' Doesn't work
myobj.NestedObj.Whatever = "hello" ' Works! And the changes stick!
Is there anyway to prevent this?
- Don