title: Remove object from generic list by id
body: <p>I have a domain class like this:</p>
  
  <pre><code>public class DomainClass
  {
    public virtual string name{get;set;}
    public virtual IList&lt;Note&gt; Notes{get;set;}
  }
  </code></pre>
  
  <p>How would I go about removing an item from the <code>IList&lt;Note&gt;</code>? I would be able to do it if it was a List but it has to be an <code>IList</code> as I am using Nhibernate for my persistance layer.</p>
  
  <p>Ideally I wanted a method like this in my domain class:</p>
  
  <pre><code>public virtual void RemoveNote(int id)
  {
     //remove the note from the list here
  
     List&lt;Note&gt; notes = (List&lt;Note&gt;)Notes
  
     notes.RemoveAll(delegate (Note note)
     {
         return (note.Id = id)
     });
  }
  </code></pre>
  
  <p>But I can't cast the <code>IList</code> as a <code>List</code>. Is there a more elegant way round this?</p>