string[] names = listBox1.Items.Cast<string>().ToArray(); List<string> namecount = ( names.GroupBy(name => name).Select(group => string.Format("{0} [{1}]", group.Key, group.Count())) .ToList());//.ForEach(item => Console.WriteLine(item)); listBox2.DataSource = namecount;
List<string> namecount = ( names.GroupBy(name => name).OrderBy(g => g.Count()).Select(group => string.Format("{0} [{1}]", group.Key, group.Count())) .ToList());
listBox1.Name = "listBox1"; listBox1.Items.AddRange(new object[] { "hi", "are", "hello", "how", "wher"}); listbox1.sort = true;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)