Home All Groups Group Topic Archive Search About

creating an array as property of a class

Author
15 Apr 2005 5:57 PM
John Devlon
Hi

does anyone know how to create an array as property of a class ?

can such an array be redimed ?

Thanx

John

Author
15 Apr 2005 6:11 PM
Herfried K. Wagner [MVP]
"John Devlon" <johndev***@hotmail.com> schrieb:
> does anyone know how to create an array as property of a class ?

\\\
Private m_Names() As String

Public Property Names() As String()
    Get
        Return m_Names
    End Get
    Set(ByVal Value() As String)
        m_Names = Value
    End Set
End Property
///

> can such an array be redimed ?

Yes.  The property only provides access to the array object.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
15 Apr 2005 11:15 PM
John Devlon
Dear Mr. Wagner,

your the best, it works like a charme ...

John


Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
news:Ol1HcYeQFHA.924@TK2MSFTNGP14.phx.gbl...
> "John Devlon" <johndev***@hotmail.com> schrieb:
>> does anyone know how to create an array as property of a class ?
>
> \\\
> Private m_Names() As String
>
> Public Property Names() As String()
>    Get
>        Return m_Names
>    End Get
>    Set(ByVal Value() As String)
>        m_Names = Value
>    End Set
> End Property
> ///
>
>> can such an array be redimed ?
>
> Yes.  The property only provides access to the array object.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
16 Apr 2005 8:17 AM
Cor Ligthert
John,

Although nothing is impossible you would not want this.

The nicest way when  you are building classes is in my opinion the use of
the CollectionBase and that extended when sort is needed with IComparer.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionscollectionbaseclasstopic.asp

I hope this helps,

Cor
Author
16 Apr 2005 10:47 AM
Herfried K. Wagner [MVP]
"Cor Ligthert" <notmyfirstn***@planet.nl> schrieb:
> Although nothing is impossible you would not want this.

Why not?  Using array properties is a common practice which is used in the
..NET Framework too (e.g. 'Environment.GetLogicalDrives').

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
16 Apr 2005 11:02 AM
Cor Ligthert
Herfried,

> Why not?  Using array properties is a common practice which is used in the
> .NET Framework too (e.g. 'Environment.GetLogicalDrives').
>
I never will use a fixed array that has to be redimed.

When there was not the asked redim I did not see any disadvantage.

Cor