title: dynamic array(or list) of objects in c#?
body: <p>I'm trying this code:</p>
  
  <pre><code>private List&lt;book&gt; books;
  //private book[] books;
  .
  .
  .
  private void button1_Click(object sender, EventArgs e)
          {
              books.Add(new book(book_name.Text));
              //book[0]=new book(book_name.Text);
          }
  </code></pre>
  
  <p>but I'm getting this error:</p>
  
  <blockquote>
    <p>'Object reference not set to an instance of an object.'</p>
  </blockquote>
  
  <p>What should I do? I want dynamic creation of object by an event.</p>