Solved

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

Posted on 2007-03-19
1
2,839 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

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…
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 …
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

689 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