Home All Groups Group Topic Archive Search About
Author
9 Jul 2006 11:48 AM
Pedro
Is it possible to have a property with its GET to public and its SET to
private or friend?

or vice versa

Author
9 Jul 2006 12:56 PM
Theo Verweij
This was possible in VB6, but as far as I know not in .Net

But, you can simulate it like this:

Private fStorageField as string

Public Readonly Propery StorageField() As String
   Get
     Return fStorageField
   End Get
End Property

Private, you use fStorageField (which is RW), and public you use
Storagefield (Which is RO)

Or, the other way around:
Private fStorageField as string

Public Writeonly Propery StorageField() As String
   Set(ByVal value as string)
     fStorageField = value
   End Get
End Property

Private, you use fStorageField (which is RW), and public you use
Storagefield (Which is WO)

Instead of private, you can also use Friend.



Pedro wrote:
Show quoteHide quote
> Is it possible to have a property with its GET to public and its SET to
> private or friend?
>
> or vice versa
>
>
Author
9 Jul 2006 5:56 PM
Herfried K. Wagner [MVP]
"Theo Verweij" <tverw***@xs4all.nl> schrieb:
> This was possible in VB6, but as far as I know not in .Net

It's possible in VB 2005 again!

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
9 Jul 2006 8:19 PM
Michel Posseth [MCP]
> It's possible in VB 2005 again!

And again we saw a feature that was already known in VB6 return to VB.net
:-)


regards

Michel Posseth [MCP]


Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
news:%23DEM9D4oGHA.504@TK2MSFTNGP05.phx.gbl...
> "Theo Verweij" <tverw***@xs4all.nl> schrieb:
>> This was possible in VB6, but as far as I know not in .Net
>
> It's possible in VB 2005 again!
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
10 Jul 2006 2:40 PM
Theo Verweij
And thats why I waited till VB2005 before I went away from VB6 ;-)

Michel Posseth [MCP] wrote:
Show quoteHide quote
>> It's possible in VB 2005 again!
>
> And again we saw a feature that was already known in VB6 return to VB.net
> :-)
>
>
> regards
>
> Michel Posseth [MCP]
>
>
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
> news:%23DEM9D4oGHA.504@TK2MSFTNGP05.phx.gbl...
>> "Theo Verweij" <tverw***@xs4all.nl> schrieb:
>>> This was possible in VB6, but as far as I know not in .Net
>> It's possible in VB 2005 again!
>>
>> --
>> M S   Herfried K. Wagner
>> M V P  <URL:http://dotnet.mvps.org/>
>> V B   <URL:http://classicvb.org/petition/>
>
>
Author
9 Jul 2006 1:05 PM
Göran_Andersson
Pedro wrote:
> Is it possible to have a property with its GET to public and its SET to
> private or friend?
>
> or vice versa
>
>

Yes. Example from MSDN:

public string Name
{
     get
     {
         return name;
     }
     protected set
     {
         name = value;
     }
}
Author
9 Jul 2006 1:10 PM
Theo Verweij
Yust learned something today!
It works also in VB!

Göran Andersson wrote:
Show quoteHide quote
> Pedro wrote:
>> Is it possible to have a property with its GET to public and its SET
>> to private or friend?
>>
>> or vice versa
>>
>>
>
> Yes. Example from MSDN:
>
> public string Name
> {
>     get
>     {
>         return name;
>     }
>     protected set
>     {
>         name = value;
>     }
> }
Author
9 Jul 2006 4:43 PM
Göran_Andersson
Right. Sorry about posting C# code in the VB forum.

Theo Verweij wrote:
Show quoteHide quote
> Yust learned something today!
> It works also in VB!
>
> Göran Andersson wrote:
>> Pedro wrote:
>>> Is it possible to have a property with its GET to public and its SET
>>> to private or friend?
>>>
>>> or vice versa
>>>
>>>
>>
>> Yes. Example from MSDN:
>>
>> public string Name
>> {
>>     get
>>     {
>>         return name;
>>     }
>>     protected set
>>     {
>>         name = value;
>>     }
>> }
>