Solved

Array to ArrayList in Property of Class

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

809 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