La pregunta es si usted tiene un dentado o una matriz multidimensional ... aquí es cómo recuperar un valor entre:
int[,] rectArray = new int[3,3]
{
{0,1,2}
{3,4,5}
{6,7,8}
};
int i = rectArray[2,2]; // i will be 8
int[][] jaggedArray = new int[3][3]
{
{0,1,2}
{3,4,5}
{6,7,8}
};
int i = jaggedArray[2][2]; //i will be 8
EDIT: Añadido para hacer frente a la parte rebanada ...
Para obtener una matriz int de una de estas matrices, debería realizar un bucle y recuperar los valores que busca. Por ejemplo:
public IEnumerable<int> GetIntsFromArray(int[][] theArray) {
for(int i = 0; i<3; i++) {
yield return theArray[2][i]; // would return 6, 7 ,8
}
}
¿Qué significa' 'this' hacer en este T [,] array' –
@Hamish Grubijan?: convierte el método estático en un [método de extensión] (http://msdn.microsoft.com/en-us/library/bb383977.aspx). – dtb
no se le extravía el índice de 'row' aquí como pensé que se debería ser 'array [row, column]'? – tsul