Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / July 2007

Tip: Looking for answers? Try searching our database.

Array in a property

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Q - 31 Jul 2007 10:46 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??

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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.