title: How to multiply a matrix in C#?
body: <p>I cannot get this method to work. It intends to multiply a matrix by a given one. Could someone help me to correct it please?</p>
  
  <pre><code>    class Matriz
      {
          public double[,] structure;
  
          //Other class methods
  
          public void multiplyBy(Matrix m)
          {
              if (this.structure.GetLength(1) == m.structure.GetLength(0))
              {
                  Matriz resultant = new Matriz(this.structure.GetLength(0), m.structure.GetLength(1));
                  for (int i = 0; i &lt; this.structure.GetLength(0) - 1; i++)
                  {
                      for (int j = 0; j &lt; m.structure.GetLength(1) - 1; j++)
                      {
                          resultant.structure[i, j] = 0;
                          for (int z = 0; z &lt; this.structure.GetLength(1) - 1; z++)
                          {
                              resultant.structure[i, j] += this.structure[i, z] * m.structure[z, j];
                          }
                      }
                  }
                  this.structure= resultant.structure;
              }
              else
              {
                  Console.WriteLine("Selected matrixs cannot be multiply");
              }
          }
      }
  </code></pre>