Home All Groups Group Topic Archive Search About

Property: ReadOnly on public scope while Read-Write on friend or private scope

Author
19 Jul 2006 8:13 AM
Saran
Hi,

    Below is my scenario...

     I want to restrict my clients to access one of my class property
in ReadOnly mode. At the same time as an author of the component i
would like to have read-write access on it.

     I tried to write 'Public ReadOnly' and 'Private WriteOnly', but
didn't work.

     Is there a way other than doing (i) direct variable access or (ii)
through another property/method with a different name?

Thanks,
Saran.

Author
19 Jul 2006 9:43 AM
Larry Lard
Saran wrote:
> Hi,
>
>     Below is my scenario...
>
>      I want to restrict my clients to access one of my class property
> in ReadOnly mode. At the same time as an author of the component i
> would like to have read-write access on it.
>
>      I tried to write 'Public ReadOnly' and 'Private WriteOnly', but
> didn't work.
>
>      Is there a way other than doing (i) direct variable access or (ii)
> through another property/method with a different name?

VB 2002/3: No
VB 2005: Yes:

     Public Property Foo() As String
         Get

         End Get
         Private Set(ByVal value As String)

         End Set
     End Property

Clients will not be able to Set the property.


--
Larry Lard
larryl***@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Author
19 Jul 2006 10:13 AM
Saran
Larry... thanks for the info.