title: Why am I receiving an System.InvalidCastException when I am trying to call my ShowStatement method?
body: <p>I am able to add accounts of different types through another form to the list statements which I can then add to the list box lstaccounts. However, when I select an account in my list box and press the view statement button I get that exception on the 'lblBank.Text = ShowStatement((IStatement)lstAccounts.SelectedItem);' line... any idea why this could be happening?</p>
  <pre><code> public List&lt;IStatement&gt; statements;       
      private int accountCounter = 0;
      private int statementsViewed = 0;
  
      public Form1()
      {
          InitializeComponent();           
      }
  
      private void Form1_Load(object sender, EventArgs e)
      {
          statements = new List&lt;IStatement&gt;();           
      }
  
      private void btnView_Click(object sender, EventArgs e)
      {
          if (lstAccounts.SelectedIndex &gt; -1)
          {
              lblBank.Text = ShowStatement((IStatement)lstAccounts.SelectedItem);
              statementsViewed += 1;
              lblTotal.Text = statementsViewed.ToString();
          }
      }
  
      private string ShowStatement(IStatement item)
      {
          String msg = &quot;Account Number: &quot; + item.AccountNumber + &quot;\n&quot; 
                      + &quot;Name: &quot;  + item.AccountName  + &quot;\n&quot; + item.PrintStatement();
          return msg;
      }
  
      private void btnAddAccount_Click(object sender, EventArgs e)
      {
          Form2 form2 = new Form2();
  
          if(form2.ShowDialog() == DialogResult.OK)
          {
              if (form2.txtValue.Text == &quot;&quot; &amp;&amp; form2.txtMinMonthly.Text == &quot;&quot;)
              {
                  BankAccount b = form2.GetBankAccount();
                  statements.Add(b);
              }
  
              else if (form2.txtMinMonthly.Text == &quot;&quot;)
              {
                  InsurancePolicy i = form2.GetInsurancePolicy();
                  statements.Add(i);
              }
  
              else
              {
                  PlatinumCurrent p = form2.GetPlatinumCurrent();
                  statements.Add(p);                 
              }
  
              foreach (IStatement os in statements)
              {
                  lstAccounts.Items.Add(os.ToString());
                  accountCounter += 1;
              }
          }
      }
  </code></pre>
  <p>The exact error I'm getting is: System.InvalidCastException: 'Unable to cast object of type 'System.String' to type 'TelephoneBanking.IStatement'.'</p>