Solved

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

Posted on 2007-03-19
1
2,834 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
ID: 18746962
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 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

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 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