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

    • <bdo id='Kyw65'></bdo><ul id='Kyw65'></ul>

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

      <small id='Kyw65'></small><noframes id='Kyw65'>

        <tfoot id='Kyw65'></tfoot>
      1. HashSet 转换为 List

        时间:2023-10-25

          <small id='KkZGX'></small><noframes id='KkZGX'>

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

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

                <bdo id='KkZGX'></bdo><ul id='KkZGX'></ul>

                    <tbody id='KkZGX'></tbody>
                  本文介绍了HashSet 转换为 List的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在网上查到了这个,但我问这个是为了确保我没有错过任何东西.C# 中是否有将 HashSet 转换为 List 的内置函数?我需要避免重复元素,但我需要返回一个列表.

                  I have looked this up on the net but I am asking this to make sure I haven't missed out on something. Is there a built-in function to convert HashSets to Lists in C#? I need to avoid duplicity of elements but I need to return a List.

                  推荐答案

                  我会这样做:

                     using System.Linq;
                     HashSet<int> hset = new HashSet<int>();
                     hset.Add(10);
                     List<int> hList= hset.ToList();
                  

                  根据定义,HashSet 不包含重复项.所以不需要Distinct.

                  HashSet is, by definition, containing no duplicates. So there is no need for Distinct.

                  这篇关于HashSet 转换为 List的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何为 webBrowser 导航事件设置超时 下一篇:在 linq 中设置相等

                  相关文章

                      <small id='g5NQm'></small><noframes id='g5NQm'>

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

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

                      <tfoot id='g5NQm'></tfoot>