• <tfoot id='5JWSk'></tfoot>
  • <i id='5JWSk'><tr id='5JWSk'><dt id='5JWSk'><q id='5JWSk'><span id='5JWSk'><b id='5JWSk'><form id='5JWSk'><ins id='5JWSk'></ins><ul id='5JWSk'></ul><sub id='5JWSk'></sub></form><legend id='5JWSk'></legend><bdo id='5JWSk'><pre id='5JWSk'><center id='5JWSk'></center></pre></bdo></b><th id='5JWSk'></th></span></q></dt></tr></i><div id='5JWSk'><tfoot id='5JWSk'></tfoot><dl id='5JWSk'><fieldset id='5JWSk'></fieldset></dl></div>

      • <bdo id='5JWSk'></bdo><ul id='5JWSk'></ul>

    1. <small id='5JWSk'></small><noframes id='5JWSk'>

    2. <legend id='5JWSk'><style id='5JWSk'><dir id='5JWSk'><q id='5JWSk'></q></dir></style></legend>

        如何从 List&lt;string&gt; 中查找所有重复项

        时间:2023-08-27
          <bdo id='nl6ee'></bdo><ul id='nl6ee'></ul>
          <tfoot id='nl6ee'></tfoot>

        • <small id='nl6ee'></small><noframes id='nl6ee'>

                  <tbody id='nl6ee'></tbody>
                • <legend id='nl6ee'><style id='nl6ee'><dir id='nl6ee'><q id='nl6ee'></q></dir></style></legend>

                  <i id='nl6ee'><tr id='nl6ee'><dt id='nl6ee'><q id='nl6ee'><span id='nl6ee'><b id='nl6ee'><form id='nl6ee'><ins id='nl6ee'></ins><ul id='nl6ee'></ul><sub id='nl6ee'></sub></form><legend id='nl6ee'></legend><bdo id='nl6ee'><pre id='nl6ee'><center id='nl6ee'></center></pre></bdo></b><th id='nl6ee'></th></span></q></dt></tr></i><div id='nl6ee'><tfoot id='nl6ee'></tfoot><dl id='nl6ee'><fieldset id='nl6ee'></fieldset></dl></div>
                  本文介绍了如何从 List&lt;string&gt; 中查找所有重复项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个 List<string> 有一些重复的单词.我需要找到所有重复的单词.

                  I have a List<string> which has some words duplicated. I need to find all words which are duplicates.

                  有什么技巧可以全部搞定吗?

                  Any trick to get them all?

                  推荐答案

                  在 .NET framework 3.5 及更高版本中,您可以使用 Enumerable.GroupBy 来返回重复键的可枚举,然后过滤取出任何具有 <=1 的 Count 的枚举,然后选择它们的键以返回到单个枚举:

                  In .NET framework 3.5 and above you can use Enumerable.GroupBy which returns an enumerable of enumerables of duplicate keys, and then filter out any of the enumerables that have a Count of <=1, then select their keys to get back down to a single enumerable:

                  var duplicateKeys = list.GroupBy(x => x)
                                          .Where(group => group.Count() > 1)
                                          .Select(group => group.Key);
                  

                  这篇关于如何从 List&lt;string&gt; 中查找所有重复项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何合并2个List&lt;T&gt;并在 C# 中从中删除重 下一篇:删除列表中的重复对象 (C#)

                  相关文章

                  最新文章

                    <legend id='iVHWD'><style id='iVHWD'><dir id='iVHWD'><q id='iVHWD'></q></dir></style></legend>

                        <bdo id='iVHWD'></bdo><ul id='iVHWD'></ul>
                    1. <i id='iVHWD'><tr id='iVHWD'><dt id='iVHWD'><q id='iVHWD'><span id='iVHWD'><b id='iVHWD'><form id='iVHWD'><ins id='iVHWD'></ins><ul id='iVHWD'></ul><sub id='iVHWD'></sub></form><legend id='iVHWD'></legend><bdo id='iVHWD'><pre id='iVHWD'><center id='iVHWD'></center></pre></bdo></b><th id='iVHWD'></th></span></q></dt></tr></i><div id='iVHWD'><tfoot id='iVHWD'></tfoot><dl id='iVHWD'><fieldset id='iVHWD'></fieldset></dl></div>
                    2. <small id='iVHWD'></small><noframes id='iVHWD'>

                      <tfoot id='iVHWD'></tfoot>