int[][] arr = new int [4];
Error 1 Cannot implicitly convert type 'int[]' to 'int[][]' D:\CODING\Visual Studio 2012\ConsoleApplication5\ConsoleApplication5\Program.cs 13 27 ConsoleApplication5
Know the answer? Post it. Somebody with the same question will find it here.
Bhushan BhasmeRank #2,348 · 604 reputationPosted Jun 19, 2015, 4:23 AM EDT
int[][] arr = new int [4]; Here You Are Taking Mulidiamensional array but You are Not column size int[,] array2D = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; // The same array with dimensions specified. int[,] array2Da = new int[4, 2] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; if You dont want to specify Column size then You can Do it Like int[][] arr = new int[3][];(Jagged Array:column size Is Not Fixed)Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Jun 19, 2015, 4:44 AM EDT
Julin James25 reputationPosted Jun 19, 2015, 4:58 AM EDT
Ramesh MaruthiRank #937 · 2.2K reputationPosted Jun 19, 2015, 5:47 AM EDT
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Jun 19, 2015, 4:39 PM EDT
int n;
for (int i = 0; i < 4; i++)
{
Console.WriteLine("Enter Number of Element for Arr{0}", i + 1);
int.TryParse(Console.ReadLine().ToString(), out n);
arr[i] = new int[n];
}
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts