title: Attempting to iterate through exisitng items, checking if each exists in list provided, removing if it does not
body: <p>I am attempting to iterate through existing sounds (isolatedGroup) and checking if each still exists in the list provided by assetsGroup. If not, I want it removed.  I am getting 3 errors when I add the portion of code for iterating. </p>
  
  <p>Errors:</p>
  
  <pre><code>Operator '&lt;' cannot be applied to operands of type 'int' and 'method group'
  
  Cannot apply indexing with [] to an expression of type SaveSoundGroup' 
  
  .SaveSoundGroup' does not contain a definition for 'RemoveAt' and no extension method    'RemoveAt' accepting a first argument of type .SaveSoundGroup' could be found (are you missing a using directive or an assembly reference?)  
  </code></pre>
  
  <p>The errors occur at </p>
  
  <pre><code>for (int i = 0; i &lt; isolatedGroup.Count; i++)
          {
              if (!assetsGroup.Contains(isolatedGroup[i]))
              {
                  isolatedGroup.RemoveAt(i);
                  i--;
              }
  </code></pre>
  
  <p>Full code:</p>
  
  <pre><code>private SoundGroup LoadFromXml(string xmlName)
      {
          SaveSoundGroup isolatedGroup = new SaveSoundGroup();
          SaveSoundGroup assetsGroup;
          XmlSerializer serializer = new XmlSerializer(typeof(SaveSoundGroup));
  
          using (Stream fileStream = Application.GetResourceStream(new Uri("Xmls/" + xmlName, UriKind.Relative)).Stream)
          {
              assetsGroup = (SaveSoundGroup)serializer.Deserialize(fileStream);
          }
  
          if (IsolatedStorageFile.GetUserStoreForApplication().FileExists(xmlName))
          {
              using (Stream fileStream = IsolatedStorageFile.GetUserStoreForApplication().OpenFile(xmlName, FileMode.Open, FileAccess.Read))
              {
                  isolatedGroup = (SaveSoundGroup)serializer.Deserialize(fileStream);
              }
  
              foreach (var entry in assetsGroup.Items)
              {
                  if (!isolatedGroup.Items.Contains(entry))
                  {
                      isolatedGroup.Items.Add(entry);
                  }
  
              }
              for (int i = 0; i &lt; isolatedGroup.Count; i++)
              {
                  if (!assetsGroup.Contains(isolatedGroup[i]))
                  {
                      isolatedGroup.RemoveAt(i);
                      i--;
                  }
              }
          }
          else
          {
              isolatedGroup = assetsGroup;
          }
  
          return new SoundGroup(isolatedGroup);
      }
  </code></pre>
  
  <p>SavedSoundGroup code:</p>
  
  <pre><code>public class SoundGroup
  {
      public string Title { get; set; }
      public List&lt;Group&lt;SoundData&gt;&gt; Items { get; set; }
  
      public SoundGroup()
      {
          Items = new List&lt;Group&lt;SoundData&gt;&gt;();
      }
  
      public SoundGroup(SaveSoundGroup data)
      {
          this.Title = data.Title;
          this.Items = new List&lt;Group&lt;SoundData&gt;&gt;();
  
          foreach (var group in data.Items.GroupBy(item =&gt; item.Groups))
          {
              this.Items.Add(new Group&lt;SoundData&gt;(group.Key, group.ToList()));
          }
      }
  }
  
  public class SaveSoundGroup
  {
      public string Title { get; set; }
      public List&lt;SoundData&gt; Items { get; set; }
  
      public SaveSoundGroup()
      {
          this.Title = string.Empty;
          this.Items = new List&lt;SoundData&gt;();
      }
  
      public SaveSoundGroup(SoundGroup data)
          : this()
      {
          if (data != null)
          {
              this.Title = data.Title;
              this.Items = new List&lt;SoundData&gt;();
  
              foreach (var group in data.Items)
              {
                  this.Items.AddRange(group);
              }
          }
      }
  }
  </code></pre>
  
  <p>Sample of XML:</p>
  
  <pre><code> &lt;SaveSoundGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
   &lt;Title&gt;cellular os&lt;/Title&gt;
   &lt;Items&gt;
   &lt;SoundData&gt;
    &lt;Title&gt;** Outro Lex Ring **&lt;/Title&gt;
    &lt;FilePath&gt;https://*********/Outro_Lex_Ring.mp3&lt;/FilePath&gt;
    &lt;Groups&gt;Animals&lt;/Groups&gt;
    &lt;SavePath&gt;Outro Lex Ring.mp3&lt;/SavePath&gt;
    &lt;Status&gt;NotDownloaded&lt;/Status&gt;
    &lt;DownloadProgress&gt;0&lt;/DownloadProgress&gt;
  &lt;/SoundData&gt;
  
      &lt;SoundData&gt;
          &lt;Title&gt;Blackberry 3Beeps&lt;/Title&gt;
          &lt;FilePath&gt;https://*********/Blackberry_3Beeps.mp3&lt;/FilePath&gt;
          &lt;Groups&gt;Blackberry&lt;/Groups&gt;
          &lt;SavePath&gt;Blackberry_3Beeps.mp3&lt;/SavePath&gt;
          &lt;Status&gt;NotDownloaded&lt;/Status&gt;
          &lt;DownloadProgress&gt;0&lt;/DownloadProgress&gt;
      &lt;/SoundData&gt;
  </code></pre>