+ 1

Jagged Array VS Multidimensional Array

Hey bro's! I've already studied Python and C, and few others. So I know what an array, a vector and a matrix is... At least I thought I did (LOL!), because today on C# course I found this, and it left me really confused: What is the difference between Jagged Arrays and Multidimensional Arrays?? I did understand the syntax of both, so I made it for comparison purposes: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { int[ , ] someNums = new int[ , ] { { 1, 2 }, { 3, 4 }, { 5, 6 }, }; for (int k = 0; k < 3; k++) { for (int j = 0; j < 2; j++) { Console.Write(someNums[k, j]+" "); } Console.WriteLine(); } Console.WriteLine(); int[ ][ ] jaggedArr = new int[ ][ ] { new int[ ] {1,2}, new int[ ] {3,4}, new int[ ] {5,6} }; for (int x = 0; x < 3; x++) { for (int y = 0; y < 2; y++) { Console.Write(jaggedArr[ x ] [ y ]+" "); } Console.WriteLine(); } } } } Take a look! They seem exactly EXACTLY the same for me.. I don't know what I'm missing.. Thank you all!!

8th Apr 2020, 7:51 PM
Eduardo Franco
Eduardo Franco - avatar
2 Respostas
0
what is difference between jagged and rectungular array in c#
19th Jan 2021, 6:49 PM
Muhammad
Muhammad - avatar