Hello to the pro's,
I want to use an array in a class. This array should be visible as a
property.
Just can't seem to find out how to do it.
Maybe there are other (and more easy) solutions?
Can anyone help me??
Regards,
Q
Armin Zingler - 31 Jul 2007 11:57 GMT
> Hello to the pro's,
>
[quoted text clipped - 5 lines]
>
> Regards,
Either make the Array a Public Readonly field, or:
Private f_Items(17) As Integer
Public Property Item(ByVal Index As Integer) As Integer
Get
Return f_Items(Index)
End Get
Set(ByVal value As Integer)
f_Items(Index) = value
End Set
End Property
Armin
tommaso.gastaldi@uniroma1.it - 31 Jul 2007 12:03 GMT
you probably need something like:
Public MyArray() As String
Public MyList() As List(Of String)
second is much better. If you also need set/get (less common)
implement it as a "property".
"String" can be replaced with any type.
Tommaso
> Hello to the pro's,
>
[quoted text clipped - 7 lines]
>
> Q
Mr. Arnold - 31 Jul 2007 12:10 GMT
Hello to the pro's,
I want to use an array in a class. This array should be visible as a
property.
Just can't seem to find out how to do it.
Maybe there are other (and more easy) solutions?
Can anyone help me??
-------------
The array or arraylist should be Private
But the Property Get and Set for an item of the array should be Public.
You'll see the example in the links
http://www.developerfusion.co.uk/show/1047/2/
http://www.java2s.com/Code/VB/Data-Structure/UseArrayListtoStoreyourownclass.htm