C# loop through all MDI childer and close all other forms except the current
<p>I am working on a winforms application using c#. I have an mdi container which has a menu on the left and by pushing a button then the appropriate form is visible. If i click for ex 3 times the button which opens Form1 the 6 instances of the form are opened. Thus i thought that i have to write a method that disposes any other Form1 instances. With the following method i m looping through the MDI childer but i want some help how to close all other instances except the new one. </p>

<pre><code>  public void DisposeAllButThis(Form form)
    {
        foreach (Form frm in this.MdiChildren)
        {
            if (frm == form)
            {
                frm.Dispose();
                return;
            }
        }

    }
</code></pre>
