title: how to multiply two arrays with different sizes in C#
body: <p>I am trying to do my homework but what I am trying does not work.</p>
  
  <p>the assignment is to basically multiply 2 arrays of different sizes together( and put all three into a message box so if you could help me with as well that would be great)</p>
  
  <p>the problem is that I am getting "overflow" amounts of values, there should only be 10 but I am getting like 28</p>
  
  <p>the code I currently have is </p>
  
  <pre><code>double[] array1 = new Double[10] { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  double[] array2 = new Double[5] { 0, 1, 2, 3, 4 };
  double[] array3 = new double[10];
  int hold = 1;
  int counter = 0;
  foreach (int c in array1)
  {
      foreach(int k in array2)
      {
          if (counter &lt;= k)
          {
              array3[c] = (array1[c] * array2[c]);//edit3: array2 was wirtten with  c when copied th outcome different but still not rigth with k
          }
          else
          {
              array3[c] = (array1[c] * hold);
          }
      }
  
      foreach (int j in array3)
      {
          Console.WriteLine(array3[c]);
      }
  }
  </code></pre>
  
  <p>the out come looks like</p>
  
  <pre><code>0
  0
  0
  0
  0
  0
  0
  0
  0
  0
  6
  6
  6
  6
  6
  6
  6
  6
  6
  6
  12
  12
  12
  12
  12
  12
  12
  12
  12
  12
  20
  20
  20
  20
  20
  20
  20
  20
  20
  20
  </code></pre>
  
  <p>it should look like</p>
  
  <pre><code>0
  2
  6
  12
  20
  6
  7
  8
  9
  10
  </code></pre>
  
  <p><strong>I have check stackoverflow all ready, so please just help not link me to another question, or if you do put a comment with it saying what I need to look at.</strong></p>
  
  <p>edit: the array3 have j just gives ten 0</p>
  
  <p>edit2: the debugger is telling me what I already know I am making too many 
  values, the question is how to fix this, and only make 10 values</p>