Solved

VB.net - 2D array with double, System.Collections.Generic.List

Posted on 2007-03-19
1
2,830 Views
Last Modified: 2007-12-19
Hi

I've got a  System.Collections.Generic.List but now want 4 of these in a 2D array
e.g.
0, System.Collections.Generic.List
1,  System.Collections.Generic.List
2,  System.Collections.Generic.List
3,  System.Collections.Generic.List

so they can be accessed by ID instead of having 4  System.Collections.Generic.List with different variable names

How is this declared/updated? Thanks
0
Comment
Question by:rwallacej
1 Comment
 
LVL 1

Accepted Solution

by:
xldev earned 500 total points
Comment Utility
Well an array can not have multiple types so a 2D array with double, List will not work.

You can just have a single-dimensional array of System.Collections.Generic.List then access them with the array index like so:

        'Declare your array of generic lists
        Dim arr(4) As System.Collections.Generic.List(Of Object)

        'Add your generic lists to the array
        arr(0) = New System.Collections.Generic.List(Of Object)
        arr(1) = New System.Collections.Generic.List(Of Object)
        arr(2) = New System.Collections.Generic.List(Of Object)
        arr(3) = New System.Collections.Generic.List(Of Object)

        'Access the lists through the array using the array index
        arr(0).Add("First generic list value.")
        arr(0).Add("First generic list 2nd value.")
        arr(1).Add("Second generic list value.")

        'Update list values using the array index and the list index
        arr(0)(0) = "Change the value."
        arr(0)(1) = "Change the 2nd value."

        'Access the list values in the same way
        MessageBox.Show(arr(0)(1).ToString())

Let me know if that is what you are looking for.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

11 Experts available now in Live!

Get 1:1 Help Now