<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

        HashSet conversion to List(HashSet 转换为 List)

          <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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding and removing users from Active Directory groups in .NET(在 .NET 中的 Active Directory 组中添加和删除用户)
                  set equality in linq(在 linq 中设置相等)
                  How to set timeout for webBrowser navigate event(如何为 webBrowser 导航事件设置超时)
                  Test whether two IEnumerablelt;Tgt; have the same values with the same frequencies(测试两个IEnumerablelt;Tgt;具有相同频率的相同值)
                  How do you determine if two HashSets are equal (by value, not by reference)?(您如何确定两个 HashSet 是否相等(按值,而不是按引用)?)
                  Shorthand Accessors and Mutators(速记访问器和突变器)

                      <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>
                              <tbody id='g5NQm'></tbody>

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