title: Failed to compare two elements in the array
body: <pre><code>private SortedList&lt;ToolStripMenuItem, Form&gt; forms = new SortedList&lt;ToolStripMenuItem, Form&gt;();                
  
  private void MainForm_Load(object sender, EventArgs e)
  {
     formsAdd(menuCommandPrompt, new CommandPrompt());
     formsAdd(menuLogScreen, new LogScreen()); //Error
  }
  
  private void formsAdd(ToolStripMenuItem item, Form form)
  {
     forms.Add(item, form); //Failed to compare two elements in the array.
     form.Tag = this;
     form.Owner = this;
  }
  </code></pre>
  
  <p>I can't get that why it throws error. Error occurs on second line of form load event. </p>
  
  <p>formsAdd method simply adds form and toolstip element to the array(forms) and sets tag and owner of form to this. On second call of function, it throws an error.</p>
  
  <pre><code>CommandPrompt, LogScreen /* are */ Form //s
  menuCommandPrompt, menuLogScreen /* are */ ToolStripMenuItem //s
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/v92DM.png" alt="Error"></p>