C# remove duplicated word list

 

    

  List<string> wordsList = new List<string>();

  wordsList = File.ReadAllLines(inFilePath, Encoding.Unicode).ToList();

  wordsList = wordsList.GroupBy(x => x.ToLower()).Select(grp => grp.FirstOrDefault()).OrderBy(x => x).ToList();

  File.WriteAllLines(@"other.txt", wordsList, Encoding.Unicode);

 

  

  List<string> wordsList_ = new List<string>();
  wordsList_ = File.ReadAllLines(inFilePath, Encoding.Unicode).ToList();
  wordsList_ = wordsList_.Distinct(StringComparer.CurrentCultureIgnoreCase).OrderBy(x => x).ToList();

  File.WriteAllLines(outFilePath, wordsList_, Encoding.Unicode);

 

 

  List<string> wordsList = new List<string>();

  wordsList = File.ReadAllLines(inFilePath, Encoding.Unicode).ToList();  

  var result = wordsList.GroupBy(x => x.ToLower()).Select(grp => grp).OrderBy(x => x.Key);
  using (StreamWriter sw = new StreamWriter(outFilePath, false, Encoding.Unicode))
  {
    foreach (var item in result)
    {
      sw.WriteLine(item.FirstOrDefault() + ‘\t‘ + item.Count());
    }
  }

C# remove duplicated word list

上一篇:本地事务和分布式事务工作实践


下一篇:有关vuex的简单介绍