Solved

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

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Advice in Xamarin 21 80
Vb. Net application freezes 9 47
VS.net 2010 11 36
How to sort a list of objects using an item in an enclosed list 5 47
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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

810 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