Solved

Array to ArrayList in Property of Class

Posted on 2006-10-27
1
302 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 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