C# Call Constructor from Type while removen out of IList
<p>I have a List full of Observers</p>

<pre><code>//create the list
Class ObersverList : IList&lt;Observer&gt;
</code></pre>

<p>the class Observer is having an dynamically Form which shows some infos. I want a clean way to kill the Form.</p>

<p>In the List i implemented something like</p>

<pre><code>// preiodically call from programm to have always a nice updated list
observerlist.RemoveClosedHandles();

//observerlist.cs
public void RemoveClosedHandles() {
    _list.RemoveAll(ObserverActivePredicate);
}

private static bool ObserverActivePredicate(Oberver o) {
    return !o.HasHandle;
}
</code></pre>

<p>this caused that the ObserverList is pretty nice, and its working great, but i have to problems.
a) the observer is not killed, its just gone out of the list (no problem for me)
b) the form stays open.(thats a huge problem)</p>

<p>iwant something like using the constructor</p>

<pre><code>//observer.cs
   activate() {
      HUD = new ObserverHud();
    }
    ~Observer(){
        HUD.Close();
        HUD.Dispose(); 
    }
</code></pre>

<p>but i dont know how to call the observerdestructor and kill the element, while removing.
is there an elegant c# way or do i need to jump through the list, find the to removing element and dispose it?</p>

<p>cheers</p>
