Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. No overload for method take "0" arguments

No overload for method take "0" arguments

Scheduled Pinned Locked Moved C#
csharpdata-structureshelptutorial
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chitra4sat
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • C chitra4sat

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      C 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        C Offline
        C Offline
        chitra4sat
        wrote on last edited by
        #3

        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.

        A 1 Reply Last reply
        0
        • C chitra4sat

          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.

          A Offline
          A Offline
          abhinarulkar
          wrote on last edited by
          #4

          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.

          C 1 Reply Last reply
          0
          • A abhinarulkar

            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.

            C Offline
            C Offline
            chitra4sat
            wrote on last edited by
            #5

            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.

            S 1 Reply Last reply
            0
            • C chitra4sat

              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.

              S Offline
              S Offline
              Stefan Troschuetz
              wrote on last edited by
              #6

              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

              www.troschuetz.de

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups