Getting an array structure from a Class property

  • Thread starter Thread starter Hugh O
  • Start date Start date
H

Hugh O

Hi,
I am creating a class. I do not have any problem defining the property
statements except when an array is involved. Would someone be able to show
me the correct syntax for a Property statement to Get an entire array
instead of one element of the array.

thanks,
hugh
 
Hugh,
In addition to the other comments:

When arrays are involved I normally make the property readonly, something
like:

Public Class Person

Public ReadOnly Property Children() As Person()
Get

End Get
End Property

End Class

Note the type is "Person()" which indicates an Array Of Person. Where as
Variables can be defined either as:

Dim people() As Person

Dim people As Person()

Both of the above lines indicates an Array Of Person.


Sometimes I will define an indexed (parameterized) property instead of an
array property:

Public Class Person

Public ReadOnly Property Children(ByVal index As Integer) As Person
Get

End Get
End Property

End Class


--
Hope this helps
Jay
T.S. Bradley - http://www.tsbradley.net


| Hi,
| I am creating a class. I do not have any problem defining the property
| statements except when an array is involved. Would someone be able to
show
| me the correct syntax for a Property statement to Get an entire array
| instead of one element of the array.
|
| thanks,
| hugh
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top