int[][] myArray = new int[10][];
foreach (int[] eachArray in myArray) {
eachArray = new int[2]
}
I believe it should create an array that is
{ 0 , 0 }
{0 , 0}
.........
Jagged array is so confusing…..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This will not create the jagged array you are looking for. It’s attempting to assign a new
int[2]instance to the iteration variable, not to the slot in the original array. This won’t even compile as the iteration variable is treated asreadonlyby the compilerThe way to do this is with a for loop