No overload for method take "0" arguments
-
Hi All, I m new in Programming with C#. I have created a method by means of passing the values using the two dimensional array of type int[,]. ie., i am passing two matrix A and Matrix B and calculating the sum and sub for the two matrix A and B. and i m storing it in the Matrix C. And i am calling this method in the main program everything works fine but it shows the error as No overload for method 'AddMatrix' takes '0' arguments and the same for the 'SubMatrix' also. I want to know how to pass the values in the main program. with regards, Chitra
-
Hi All, I m new in Programming with C#. I have created a method by means of passing the values using the two dimensional array of type int[,]. ie., i am passing two matrix A and Matrix B and calculating the sum and sub for the two matrix A and B. and i m storing it in the Matrix C. And i am calling this method in the main program everything works fine but it shows the error as No overload for method 'AddMatrix' takes '0' arguments and the same for the 'SubMatrix' also. I want to know how to pass the values in the main program. with regards, Chitra
chitra4sat wrote:
everything works fine but it shows the error
How can both these things be true ?
chitra4sat wrote:
No overload for method 'AddMatrix' takes '0' arguments and the same for the 'SubMatrix' also.
Then you forgot to pass the parameters
chitra4sat wrote:
I want to know how to pass the values in the main program.
Not sure what you mean, but if you have a method int Add(int a, int b) { return a + b; } You are doing this: int n = Add(); // Can't do it, wrong number of parameters but you need to do this int n = Add( 1,2); or this int x = 1; int y = 2; int z = Add(x,y); Or any combination of the two. You probably need to post your code if you need to ask any more, so we can see what's going on.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
chitra4sat wrote:
everything works fine but it shows the error
How can both these things be true ?
chitra4sat wrote:
No overload for method 'AddMatrix' takes '0' arguments and the same for the 'SubMatrix' also.
Then you forgot to pass the parameters
chitra4sat wrote:
I want to know how to pass the values in the main program.
Not sure what you mean, but if you have a method int Add(int a, int b) { return a + b; } You are doing this: int n = Add(); // Can't do it, wrong number of parameters but you need to do this int n = Add( 1,2); or this int x = 1; int y = 2; int z = Add(x,y); Or any combination of the two. You probably need to post your code if you need to ask any more, so we can see what's going on.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
here is my code for your reference: in the main class Here i m giving the values for the matrix A & B int[,] MatrixA ={ { 1, 2 }, { 2, 3 } }; int[,] MatrixB ={ { 3, 4 }, { 4, 5 } }; public int[,] AddMatrix(int[,] MatrixA, int[,] MatrixB) { int numberOfRows = MatrixA.Length / 2; int numberOfCols = numberOfRows; int[,] MatrixC = new int[numberOfRows, numberOfCols]; for (int i = 0; i <=numberOfRows; i++) { for (int j = 0; j <=numberOfCols; j++) { MatrixC[i, j] = MatrixA[i, j] + MatrixB[i, j]; } } return MatrixC; } And i m calling this AddMatrix Method in the main program as mymatrix.AddMatrix(); in that how sould i have to pass the value let me know it ASAP. regards, Chitra.
-
here is my code for your reference: in the main class Here i m giving the values for the matrix A & B int[,] MatrixA ={ { 1, 2 }, { 2, 3 } }; int[,] MatrixB ={ { 3, 4 }, { 4, 5 } }; public int[,] AddMatrix(int[,] MatrixA, int[,] MatrixB) { int numberOfRows = MatrixA.Length / 2; int numberOfCols = numberOfRows; int[,] MatrixC = new int[numberOfRows, numberOfCols]; for (int i = 0; i <=numberOfRows; i++) { for (int j = 0; j <=numberOfCols; j++) { MatrixC[i, j] = MatrixA[i, j] + MatrixB[i, j]; } } return MatrixC; } And i m calling this AddMatrix Method in the main program as mymatrix.AddMatrix(); in that how sould i have to pass the value let me know it ASAP. regards, Chitra.
Thats what is worng chitra!! You cant call AddMatrix without parameters since you have defined your method with parameters!! What you may do is that you have to pass A and B in AddMatrix method like AddMatrix(MatrixA, MatrixB); It would work then. Hopefully!!
Learning is a never ending process of Life.
-
Thats what is worng chitra!! You cant call AddMatrix without parameters since you have defined your method with parameters!! What you may do is that you have to pass A and B in AddMatrix method like AddMatrix(MatrixA, MatrixB); It would work then. Hopefully!!
Learning is a never ending process of Life.
Hi, Thanks for ur reply. But here,i am giving the values of Matrix A and Matrix B . I have used it as int[,] matrix A={{1,2},{2,3}}; and int[,]MatrixB={{2,3}.{3,4}}; which are the values i am sending it in the program itself . and i m calling it in the main program as mymatrix.AddMatrix(); but i got doubt there only how to pass the values becoz the values are all mentioned above. i need that mymatrix.AddMatrix(" how the values to be put it here "); here if i open that method bracket it is asking the value of (int[,]matrix A,int[,]matrix B) I am getting the problem only in passing the value only . so please help me by code in passing the value of this line . waiting for ur reply ASAP. Regards, Chitra.
-
Hi, Thanks for ur reply. But here,i am giving the values of Matrix A and Matrix B . I have used it as int[,] matrix A={{1,2},{2,3}}; and int[,]MatrixB={{2,3}.{3,4}}; which are the values i am sending it in the program itself . and i m calling it in the main program as mymatrix.AddMatrix(); but i got doubt there only how to pass the values becoz the values are all mentioned above. i need that mymatrix.AddMatrix(" how the values to be put it here "); here if i open that method bracket it is asking the value of (int[,]matrix A,int[,]matrix B) I am getting the problem only in passing the value only . so please help me by code in passing the value of this line . waiting for ur reply ASAP. Regards, Chitra.
public void TestAddMarix() {
int[,] MatrixA ={ { 1, 2 }, { 2, 3 } };
int[,] MatrixB ={ { 3, 4 }, { 4, 5 } };AddMatrix(MatrixA, MatrixB);
}public int[,] AddMatrix(int[,] MatrixA, int[,] MatrixB)
{
int numberOfRows = MatrixA.Length / 2;
int numberOfCols = numberOfRows;
int[,] MatrixC = new int[numberOfRows, numberOfCols];
for (int i = 0; i <=numberOfRows; i++)
{
for (int j = 0; j <=numberOfCols; j++)
{
MatrixC[i, j] = MatrixA[i, j] + MatrixB[i, j];
}
}
return MatrixC;
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook