title: Initializing an array of objects, out of range error
body: <p>I'm starting to learn C# and I have a problem with initializing an array of objects.</p>
  <p>namespace DayAtTheRaces</p>
  <p>{</p>
  <pre><code>public partial class ADayAtTheRacesForm : Form
  {
      Guy[] guysArray = new Guy[2];
      Greyhound[] greyhoundsArray=new Greyhound[3];
  
  
      public ADayAtTheRacesForm()
      {
          InitializeComponent();
        
          guysArray[0] = new Guy { myName=&quot;Joe&quot;, MyCashInBank=50, myRadioButton=JoeRadioButton, myLabel=JoeBetLable, myBet=null };
          guysArray[1] = new Guy { myName = &quot;Rob&quot;, MyCashInBank = 75, myRadioButton = RobRadioButton, myLabel = RobBetLabel, myBet = null };
          guysArray[2] = new Guy { myName = &quot;Al&quot;, MyCashInBank = 45, myRadioButton = AlRadioButton, myLabel = AlBetLabel, myBet = null };
  
          greyhoundsArray[0] = new Greyhound { myPictureBox = DogPictureBox1, myRaceTrackPosition = DogPictureBox1.Left, raceTrackLength = RaceTrackPictureBox.Width - DogPictureBox1.Width, randomValue = null };
          greyhoundsArray[1] = new Greyhound { myPictureBox = DogPictureBox2, myRaceTrackPosition = DogPictureBox2.Left, raceTrackLength = RaceTrackPictureBox.Width - DogPictureBox2.Width, randomValue = null };
          greyhoundsArray[2] = new Greyhound { myPictureBox = DogPictureBox3, myRaceTrackPosition = DogPictureBox3.Left, raceTrackLength = RaceTrackPictureBox.Width - DogPictureBox3.Width, randomValue = null };
          greyhoundsArray[3] = new Greyhound { myPictureBox = DogPictureBox4, myRaceTrackPosition = DogPictureBox4.Left, raceTrackLength = RaceTrackPictureBox.Width - DogPictureBox4.Width, randomValue = null };
  
          for (int i = 0; i&lt;= 2; i++)
          {
              guysArray[i].ChangeLabel();
              guysArray[i].ChangeRadio();
          }
      }
  
      
      private void RaceButton_Click(object sender, EventArgs e)
      {
          for(int i=0; i&lt;=3; i++)
          {
              greyhoundsArray[i].TakeStartingPosition();
          }
      }
  
      private void BetsButton_Click(object sender, EventArgs e)
      {
         for(int i=0; i&lt;=2; i++)
          {
              if(guysArray[i].myRadioButton.Checked==true)
              {
                  if (guysArray[i].myBet != null)
                  {
                      guysArray[i].ClearBet();
                  }
                  guysArray[i].PlaceBet((int)BetAmountUpDown.Value, (int)DogNumberUpDown.Value);
                  guysArray[i].myBet.bettingGuy = guysArray[i];
                  guysArray[i].ChangeLabel();
                  guysArray[i].ChangeRadio();
                  break;
              }
          }
      }
  }
  </code></pre>
  <p>It seems to me, that I've initialized both guysArray and greyhound array in the same way, but on greyhoundsArray[0]... line I get an index out of range error and I can't figure out why.</p>