title: Object reference not set to an instance of an object w/array
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/13736884/adding-c-sharp-labels-to-a-form-at-runtime">Adding C# labels to a form at Runtime</a>  </p>
  </blockquote>
  
  
  
  <p>I can't figure out what is making this error</p>
  
  <blockquote>
    <p>Object reference not set to an instance of an object. </p>
    
    <p>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p>
    
    <p>Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.</p>
  </blockquote>
  
  <p>code:</p>
  
  <pre><code>Line[] myLine = new Line[10];
  int lineCount = 0;
  private void Form1_MouseClick(object sender, MouseEventArgs e)
  {
      if (checkBox1.CheckState == CheckState.Checked)
      {
          myLine[lineCount].setPoint(new Point(e.X, e.Y));
          ++pointCount;
          if (pointCount == 2)
          {
              pointCount = 0;
              ++lineCount;
          }
      }
  }
  </code></pre>