title: Removing duplicate items from a ListBox in C#
body: <p>I have a <code>ListBox</code> with 10 items like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>1:3
  2:2
  2:2
  2:2
  1:3
  6:8
  6:8
  9:1
  7:2
  9:1
  </code></pre>
  
  <p>I want to remove duplicates so the result looks like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>1:3
  2:2
  6:8
  9:1
  7:2
  </code></pre>
  
  <p>Here is what I have tried:</p>
  
  <pre><code>private void button2_Click(object sender, EventArgs e)
  {
      for (int p = 0; p &lt; 10; p++)
      {
          a[p] = System.Convert.ToInt32(Interaction.InputBox("Please Enter 10 Number:", "", "", 350, 350));
          listBox1.Items.Add(a[p]);
      }
  }
  
  private void button3_Click(object sender, EventArgs e)
  {
      for (int j = 0; j &lt; 10; j++)
      {
          for (int k = 0; k &lt; 10; k++)
          {
              if (a[j] == a[k])
                  b = b + 1;
          } //end of for (k)
          listBox2.Items.Add(a[j] + ":" + b);
          b = 0;
      } //end og for (j)
  }
  </code></pre>