I'm trying to make a listbox where i can add items to it using datagridview, the thing is i want to determine which item is duplicate and how many times it duplicate.
- item1
 - item1
 - item2
 - item2
 - item2
 
output item1=2, item2=3
Here is the one that i tried which shows the last item that have been duplicate
int count = 0;
 for (int i = 0; i < listBox1.Items.Count; i++)
 {
  var s = listBox1.Items[i].ToString();
  if (s.StartsWith(listfood))
   {
    if (s == listfood)
     {
      ++count;
     }             
   }
 }
MessageBox.Show(count.ToString());