Solved

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

Posted on 2007-03-19
1
2,831 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

27 Experts available now in Live!

Get 1:1 Help Now