Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int[,] arrayBidimensional = new int[3, 3]
- {
- { 1, 2, 3 },
- { 4, 5, 6 },
- { 7, 8, 9 }
- };
- using System;
- class MainClass {
- public static void Main (string[] args) {
- int[,] arrayBidimensional = new int[3, 3]
- {
- { 1, 2, 3 },
- { 4, 5, 6 },
- { 7, 8, 9 }
- };
- var novoArray = new int[arrayBidimensional.GetLength(0) * arrayBidimensional.GetLength(1)];
- int colunas = arrayBidimensional.GetLength(1);
- for(int i = 0; i < arrayBidimensional.GetLength(0); i++) {
- for(int j = 0; j < colunas; j++) {
- var indice = colunas * i + j;
- novoArray[indice] = arrayBidimensional[i, j];
- Console.WriteLine($"{indice} = {novoArray[indice]}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement