By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,517 Members | 1,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,517 IT Pros & Developers. It's quick & easy.

Array in a property

P: n/a
Q
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

Jul 31 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Q" <Q@nomail.netschrieb
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,
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
Jul 31 '07 #2

P: n/a
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
On 31 Lug, 11:46, "Q" <Q...@nomail.netwrote:
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

Jul 31 '07 #3

P: n/a

"Q" <Q@nomail.netwrote in message
news:eV**************@TK2MSFTNGP02.phx.gbl...
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-S...urownclass.htm

Jul 31 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.