matrices son siempre fijos en tamaño, y tienen que ser definidas así:
double[] items1 = new double[10];
// This means array is double[3] and cannot be changed without redefining it.
double[] items2 = {1.23, 4.56, 7.89};
La clase List<T>
utiliza una matriz en el fondo y la redefine cuando se queda sin espacio:
List<double> items = new List<double>();
items.Add(1.23);
items.Add(4.56);
items.Add(7.89);
// This will give you a double[3] array with the items of the list.
double[] itemsArray = items.ToArray();
se puede recorrer un List<T>
tal como lo haría una matriz:
foreach (double item in items)
{
Console.WriteLine(item);
}
// Note that the property is 'Count' rather than 'Length'
for (int i = 0; i < items.Count; i++)
{
Console.WriteLine(items[i]);
}
cómo puedo iterar a través de la lista – subprime
@subprime: foreach (elemento doble en los elementos) {...}, o a través de los elementos [n] indexer –
gracias! esta es la respuesta :) – subprime