I want to have an array of Lists. In c++ I do like:
List<int> a[100];
which is an array of 100 Lists. each list can contain many elements. I don't know how to do this in c#. Can anyone help me?
There's no such thing in the standard C library. People usually roll their own. While the terms vector and ArrayList usually refer to the same datastructure (resizable array), a linked list is something completely different. So do you want a resizable array or a linked list?
An array of linked lists is an important data structure that can be used in many applications. Conceptually, an array of linked lists looks as follows. An array of linked list is an interesting structure as it combines a static structure (an array) and a dynamic structure (linked lists) to form a useful data structure.
An array is a variable that can store multiple values. For example, if you want to store 100 integers, you can create an array for it. int data[100];
To create an array, define the data type (like int ) and specify the name of the array followed by square brackets []. To insert values to it, use a comma-separated list, inside curly braces: int myNumbers[] = {25, 50, 75, 100}; We have now created a variable that holds an array of four integers.
You do like this:
List<int>[] a = new List<int>[100];
Now you have an array of type List<int>
containing 100 null references. You have to create lists and put in the array, for example:
a[0] = new List<int>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With