title: Random Sentence Generator / Listbox output
body: <p>I am trying to make a windows form in <code>C#</code> that will have four arrays with 5 random words in them.  I will then create a button to generate a random sentence using the words from the array.  Right now I am trying to output the sentences to a list box but I am getting errors. What is the code to output this information to a listbox? Here is my code...</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
  namespace Chapter_16_Ex._16._4
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
          private void btnGenerator_Click(object sender, EventArgs e)
          {
              string[] article = { "the", "a", "one", "some", "any", };
              string[] noun = { "boy", "girl", "dog", "town", "car", };
              string[] verb = { "drove", "jumped", "ran", "walked", "skipped", };
              string[] preposition = { "to", "from", "over", "under", "on", };
  
              Random rndarticle = new Random();
              Random rndnoun = new Random();
              Random rndverb = new Random();
              Random rndpreposition = new Random();
  
              int randomarticle = rndarticle.Next(article.Length);
              int randomnoun = rndnoun.Next(noun.Length);
              int randomverb = rndverb.Next(verb.Length);
              int randompreposition = rndpreposition.Next(preposition.Length);
  
              listBox1.Items.Add("{0} {1}",article[randomarticle],noun[randomnoun]);
  
  
          }
  
          private void btnExit_Click(object sender, EventArgs e)
          {
              Application.Exit();
          }
      }
  }
  </code></pre>