title: Unable to cast object of type ListItem to String
body: <p>I am trying to remove specific items from a ListBox however I am getting a cast error.
  It does not seem to like the fact I have referred to the items in the ListBox as <code>string</code> items.</p>
  
  <pre><code>if (CheckBox1.Checked == true)
          {
              foreach (string item in ListBox1.Items)
              {
                  WebService1 ws = new WebService1();
                  int flag = ws.callFlags(10, item); 
  
                  if (flag == 1)
                  {
                      ListBox1.Items.Remove(item);
                  }
              }
          }
  </code></pre>
  
  <p><strong>Error</strong> -</p>
  
  <pre><code>Unable to cast object of type 'System.Web.UI.WebControls.ListItem' to type 'System.String'.
  </code></pre>
  
  <p>How can I resolve this?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>My problem being when I change to the method of <code>(ListItem item in ListBox1.Items)</code>(which I had tried) the line - <code>int flag = ws.callFlags(10, item);</code> breaks because the web service is looking to receive a <code>string</code> specifically. This then gives the error -</p>
  
  <pre><code>Error   2   Argument 2: cannot convert from 'System.Web.UI.WebControls.ListItem' to 'string'
  Error   1   The best overloaded method match for 'testFrontEnd.WebService1.callFlags(int, string)' has some invalid arguments
  </code></pre>