La domanda è se si dispone di un frastagliato o un array multidimensionale ... ecco come recuperare un valore da entrambi:
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: Aggiunto per affrontare la parte fetta ...
Per ottenere un array int da uno di questi array, dovresti eseguire il ciclo e recuperare i valori che stai cercando. Per esempio:
public IEnumerable<int> GetIntsFromArray(int[][] theArray) {
for(int i = 0; i<3; i++) {
yield return theArray[2][i]; // would return 6, 7 ,8
}
}
Cosa significa' this' fare 'questo T [,] array' –
@Hamish Grubijan?: Trasforma il metodo statico in un [metodo di estensione] (http://msdn.microsoft.com/en-us/library/bb383977.aspx). – dtb
Non hai sbagliato l'indice 'row' qui come pensavo che fosse dovrebbe essere 'array [row, column]'? – tsul