How 42 ? | Sololearn: Learn to code for FREE!

+2

How 42 ?

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[ ][ ] jaggedArr = new int[ ][ ] { new int[ ] {1,8,2,7,9}, new int[ ] {2,4,6}, new int[ ] {33,42} }; int x = jaggedArr[2][1]; Console.WriteLine(x); } } }

2/3/2020 7:32:55 PM

Ehsan Wattoo

4 Answers

New Answer

+6

Because of [2][1] Here row wise index is 2 and column wise index is 1. So will check in third array where on 1st index value is 42

+2

Imagine an array which contains 3 other arrays. The outer array has indices. And all inner arrays has indeces. jaggedArr[0][x] means the first inner array -> 1,8,2,7,9 jaggedArr[0][0] = 1 jaggedArr[0][1] = 8 jaggedArr[0][2] = 2 jaggedArr[0][3] = 7 jaggedArr[0][4] = 9 jaggedArr[2][x] means this array: 33,42 inside this array the value of index 1 is 42 -> jaggedArr[2][1] = 42

+2

Denise Roßberg thankssss bro

+2

Ehsan Wattoo Your welcome :)