title: C# Insert Array Values via for loop
body: <p><strong>Hello Everyone</strong></p>
  
  <p>What I am trying to do is call the "FillDeck" method to fill the "deck []" with 52 array elements. The for loop is used to add the elements - for testing purposes it is just adding the y+x values from the for loop. 
  What I did was use the variable "placement" to indicate my index position then increment the placement variable so for each loop iteration the index is increased thus adding an array element to that particular index. However, I get the IndexOutOfRangeException which is what I trying to figure out. </p>
  
  <p>To note: I CANNOT automatically use predetermined values for the array, I must call a method which purpose is to add the values to the array. Since it is a card deck having a nested for loop to determine the rank / suit would be a good way to approach this. </p>
  
  <p>Thanks =)</p>
  
  <pre><code>    static void Main(string[] args)
      {
          int [] deck = {};
          FillDeck(deck); // Error Here
      }
      public static void FillDeck(int[] deck)
      {
          int placement = 0;
          // 0 = Ace , 12 = King : 0 = Hearts, 1 = Diamonds, 2 = Clubs, 3 = Spades
          for (int x = 0; x &lt; 13; x++)
              for (int y = 0; x &lt; 4; ++y)
              {
                  deck[placement] = x + y;// Error here
                  ++placement;
              }
  
      }
  </code></pre>