[Solved] Count the number of unique words and occurrence of each word from txt file


Use this code

  string input = "that I have not that place sunrise beach like not good dirty beach trash beach";
        var wrodList = input.Split(null);
        var output = wrodList.GroupBy(x => x).Select(x => new Word { charchter = x.Key, repeat = x.Count() }).OrderBy(x=>x.repeat);
        foreach (var item in output)
        {
            textBoxfile.Text += item.charchter +" : "+ item.repeat+Environment.NewLine;
        }

class for holding data

 public class word
    {
        public string  charchter { get; set; }
        public int repeat { get; set; }
    }

9

solved Count the number of unique words and occurrence of each word from txt file