title: Filter string collection based on listview item
body: <p><strong>RESOLVED</strong></p>
  
  <p>Oddly, it appeared that what was happening here, was that the <code>string[]</code> collection was being iterrated through when it had no elements.  Because of that, every single item would be removed from the user list.  Added an additional check to ensure that <code>nicks.Count !=0</code>, and it adds and works perfectly.  Have to love when code does things you do not expect ;)</p>
  
  <p><strong>---[INITIAL ISSUE]---</strong></p>
  
  <p>So, i'm a bit confused here.</p>
  
  <p>When we connect to our server, we are given a string collection result <code>string[]</code>.  We then parse that string collection, and add names to a listview.  However, we need to also parse the listview, and remove any items which do not appear in the string collection.</p>
  
  <p>I can't seem to figure out a way to properly do that.  I know it's easy, but I've failed so far at anything I've tried, which totally isn't cool :(</p>
  
  <p>Code to filter out the string collection to the listview and not add duplicates:</p>
  
  <pre><code>foreach (var nick in nicks)
          {
              if (string.IsNullOrEmpty(nick)) continue;
              var lvi = new ListViewItem
                            {
                                Text = nick,
                                Group = nick.StartsWith("@") ? listViewEx1.Groups[0] : listViewEx1.Groups[1]
                            };
              if (listViewEx1.Items.Count != 0)
              {
                  var foundItem = listViewEx1.FindItemWithText(nick, true, 0, false);
                  if (foundItem != null) continue;
              }
              lvi.ImageIndex = 0;
              listViewEx1.Items.Add(lvi);
          }
  </code></pre>
  
  <p>So, how can I conversely compare the items in the listview, with the items in the string collection, and remove those that do not exist?</p>
  
  <p><strong>Debug Information</strong></p>
  
  <pre><code>Element in 'nicks':   Bot
  Element in 'nicks':   Test
  Element in 'nicks':   @Mike
  Element in 'nicks':   @Jack
  Element in 'nicks':   Joe
  Element in 'nicks':   Nancy
  Element in 'nicks':   Roger
  Element in 'nicks':   
  Does not contain:  @Mike
  Does not contain:  @Jack
  Does not contain:  Bot
  Does not contain:  Joe
  Does not contain:  Test
  Does not contain:  Nancy
  Does not contain:  Roger
  </code></pre>
  
  <p>So oddly, even though the <code>nicks[]</code> collection contains the item, and the <code>item.Text</code> contains the nick, the <code>.Contains()</code> call is not matching it.</p>