Solved

Array to ArrayList in Property of Class

Posted on 2006-10-27
1
298 Views
Last Modified: 2012-06-22
I have one-dimensional and two-dimensional arrays to convert to ArrayList instead. What would be the equivalent code for:

    Private _mySmallArray(10) As Single
    Public Property MySmallArray As Single()
        Get
            Return _mySmallArray
        End Get
        Set(ByVal Value As Single())
            _mySmallArray = Value
        End Set
    End Property

    Private _myBigArray(10, 10) As Single
    Public Property MyBigArray() As Single(,)
        Get
            Return _myBigArray
        End Get
        Set(ByVal Value As Single(,))
            _myBigArray = Value
        End Set
    End Property

That way, I can still do things like:

 MySmallArray(3) = 3.33
 MyBigArray(4,5) = 4.5
0
Comment
Question by:GivenRandy
1 Comment
 
LVL 4

Accepted Solution

by:
Xeavn earned 500 total points
ID: 17821947
Why are you trying to convert to an Arraylist? It looks like you are making pretty good use of the regular arrays, is there a reason for wanting to switch?

For the single array you can switch by doing

Private _myArrayList As Arraylist
Protected Property alSmallArray As ArrayList
   Get
      If _myArrayList Is Nothing Then
         _myArrayList = New ArrayList()
      End If
      Return _myArrayList
   End Get
   Set(ByVal Value As ArrayList)
      _myArrayList = Value
   End Set
End Property 'alSmallArray

alSmallArray.Item(3) = 3.33

Not sure how you would even make ArrayList work for a 2 Dimensional Array.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now