Dennis,
Yes - you can do it via Reflection as well although it would be a little
slower. Here's how:
Public Class Testclass
Private Field As Integer = 1
Private Property TestProp() As Integer
Get
Return Field
End Get
Set(ByVal Value As Integer)
Field = Value
End Set
End Property
End Class
Private Sub TestMethod()
Dim o As New Testclass
o.GetType.GetPr operty("TestPro p", _
Reflection.Bind ingFlags.Instan ce Or _
Reflection.Bind ingFlags.NonPub lic).SetValue(o , 3, Nothing)
End Sub
However, what you've come up with is also a decent solution to this problem.
You can choose either of these methods.
hope that helps..
Imran.
"Dennis" <De****@discuss ions.microsoft. com> wrote in message
news:65******** *************** ***********@mic rosoft.com...
Thanks for answers. I resorted to using two properties, one public
readonly
and the other Friend for readWrite. I thought I had seen an example on
this
news group using reflection to write to private proerties. Thanks again.
"Dennis" wrote:
How do I access a private property of a class from outside the class. I
have
a class that has a property which I want to access in my code for
read/write
but allow end users to only read.
--
Dennis in Houston