[Solved] Count equal strings in a list of string and make them unique


This can be done with Linq and the GroupBy function pretty easily:

var input = new string[]
    {
        "welcome guys",
        "guys and", 
        "and ladies",
        "ladies repeat",
        "repeat welcome",
        "welcome guys"
    };

var groups =
    input
    .GroupBy(x => x);

foreach (var g in groups)
{
    Console.WriteLine("{0}, {1}", g.Key, g.Count().ToString());
}

welcome guys, 2
guys and, 1
and ladies, 1
ladies repeat, 1
repeat welcome, 1

2

solved Count equal strings in a list of string and make them unique