title: C# how do I use a partially filled array in a method?
body: <p>My instructor wants us to create an array of 10 elements and then fill it with random numbers using console input and then multiply all the numbers together to get the product.  I can't figure out how to pass the array to a method and then successfully get the product.  Do I use a for loop?  I don't think I can use a foreach loop because it could be partially filled.  How do I even pass the array to the method in the first place?</p>
  
  <p>Here's what I have so far to store the values in the array.</p>
  
  <pre><code>for (int i = 0; i &lt; SIZE; i++)
  {
  
      bool valid = false;
      do
      {
           Write("Enter an integer value or 0 to stop ");
           string input = ReadLine();
           valid = int.TryParse(input, out userInput);
      } while (!valid);
  
      if (userInput == 0)
      {
           break;
      }
      array[i] = userInput;
  }
  
  product = p.ArrayProduct(array.Length);
  </code></pre>