c# - Using method 2 dimensional array? -
getting error @ (private int >>>totarray<< (int[,] array)) tells me cannot return value. can me , tell me doing wrong?
what code supposed add numbers of 2 dimensional array. in moment nothing.
int[,] = new int[3, 4] { { 4, -5, 12, -2}, { -9, 15, 19, 6}, { 18, -33, -1, 7} }; public form1() { initializecomponent(); } private int totarray(int[,] array)//<<<<<< error { int sum = 0; int rows = array.getlength(0); int cols = array.getlength(1); (int = 0; < rows; i++) { (int j = 0; j < cols; j++) { sum += array[i, j]; } } richtextbox1.text = ("the sum of array " + sum.tostring() + "."); } private void button1_click(object sender, eventargs e) { totarray(a); }
i think getting error because totarray method isn't returning int.
what happens if switch following:
private void totarray(int[,] array)
and if doesnt fix it, can post error message?
Comments
Post a Comment