Question with Vb.Net - private fields
I am looking at a class that has a method that takes a parameter that is of the same type of the class that contains that method.
Public Class test
private _avalue as integer
Public Sub CopyFrom(ByVal from as test)
_avalue = from._avalue
End Sub
End Class
When used in code
a.CopyFrom(b)
It looks like instance "a" has visibility to private members passed in instance "b" and string
_avalue = from._avalue
runs without error by copying the private field from one instance of the object to another.
Does anyone know if this is by design. I was under the impression that the private field is only accessible to the object instance.
+2
source to share
2 answers