How to access the elements of an array Arraylist? [closed]

0

How could I access this type of arraylist?

List<String[]> arraylist1= new List<String[]>;
String[] splits = Str.Split(';');

The question is, how can I get the information for the second position in the array?

_____________________
|List<String[]>      |
|____________________|
|[0]                 |
|____________________|
|   [0]"Juan"        |
|   [1]"Garcia"      |
|   [2]"Lorca"       |
|____________________|
|[1]                 |
|____________________|
|   [0]"Pepe"        |
|   [1]"Apellido"    |
|   [2]"Apellido2"   |
|                    |
|____________________|

As a simple example, let's say that later I want to do something of the type:

Console.Write(Arraylist1[0][1]);
    
asked by Aritzbn 04.12.2017 в 13:37
source

1 answer

2

You can do it in the following way:

Arraylist.ElementAt(0)[1]  //Con Arraylist.ElementAt(0) tenemos el primer elemento de la lista y con [1] accedemos al apellido

Or you can also do it this way if you want to go through the list

foreach(String[] s in Arraylist)
{
    Console.Write(s[1]);  //s es el elementpo de la lista en el que estemos en cada iteración, [1] es el apellido
}
    
answered by 04.12.2017 / 13:51
source