• <bdo id='1ZOKj'></bdo><ul id='1ZOKj'></ul>

    1. <tfoot id='1ZOKj'></tfoot>

      1. <legend id='1ZOKj'><style id='1ZOKj'><dir id='1ZOKj'><q id='1ZOKj'></q></dir></style></legend>
      2. <small id='1ZOKj'></small><noframes id='1ZOKj'>

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

        您如何确定两个 HashSet 是否相等(按值,而不是按引用)?

        How do you determine if two HashSets are equal (by value, not by reference)?(您如何确定两个 HashSet 是否相等(按值,而不是按引用)?)

        <legend id='yGVAv'><style id='yGVAv'><dir id='yGVAv'><q id='yGVAv'></q></dir></style></legend>
        • <bdo id='yGVAv'></bdo><ul id='yGVAv'></ul>
                  <tbody id='yGVAv'></tbody>

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

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

                • 本文介绍了您如何确定两个 HashSet 是否相等(按值,而不是按引用)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试确定 .NET 3.5 (C#) 中的两个 HashSet 对象是否是相等的集合,包含相同的值.这似乎是一个显然想要做的事情,但所提供的功能似乎都没有为您提供这些信息.

                  I am trying to determine if two HashSet objects in .NET 3.5 (C#) are equal sets, i.e. contain the same values. This seems like something one would obviously want to do but none of the provided functions seem to give you this information.

                  我能想到的方法是检查两个集合的计数是否相等并且一个集合是另一个集合的子集(不正确).我认为可能发生的唯一方法是它们是相等的集合.示例代码:

                  The way I can think to do this is by checking if the count of the two sets are equal and one set is a subset (not proper) of the other. I think the only way that can happen is if they are equal sets. Example code:

                  HashSet<int> set1 = new HashSet<int>();
                  set1.Add(1);
                  set1.Add(2);
                  set1.Add(3);
                  
                  HashSet<int> set2 = new HashSet<int>();
                  set2.Add(1);
                  set2.Add(2);
                  set2.Add(3);
                  
                  if(set1.Count == set2.Count && set1.IsSubsetOf(set2))
                  {
                      // do something
                  }
                  

                  这总是有效吗?有没有更好的办法?为什么HashSet没有public bool IsEqualSetWith()函数?

                  Would this always work? Is there a better way? Why doesn't HashSet have a public bool IsEqualSetWith() function?

                  推荐答案

                  看方法SetEquals.

                  my_hashset.SetEquals(other);
                  

                  这篇关于您如何确定两个 HashSet 是否相等(按值,而不是按引用)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Adding and removing users from Active Directory groups in .NET(在 .NET 中的 Active Directory 组中添加和删除用户)
                  set equality in linq(在 linq 中设置相等)
                  HashSet conversion to List(HashSet 转换为 List)
                  How to set timeout for webBrowser navigate event(如何为 webBrowser 导航事件设置超时)
                  Test whether two IEnumerablelt;Tgt; have the same values with the same frequencies(测试两个IEnumerablelt;Tgt;具有相同频率的相同值)
                  Shorthand Accessors and Mutators(速记访问器和突变器)
                    <bdo id='Re1x8'></bdo><ul id='Re1x8'></ul>
                    <i id='Re1x8'><tr id='Re1x8'><dt id='Re1x8'><q id='Re1x8'><span id='Re1x8'><b id='Re1x8'><form id='Re1x8'><ins id='Re1x8'></ins><ul id='Re1x8'></ul><sub id='Re1x8'></sub></form><legend id='Re1x8'></legend><bdo id='Re1x8'><pre id='Re1x8'><center id='Re1x8'></center></pre></bdo></b><th id='Re1x8'></th></span></q></dt></tr></i><div id='Re1x8'><tfoot id='Re1x8'></tfoot><dl id='Re1x8'><fieldset id='Re1x8'></fieldset></dl></div>
                    <legend id='Re1x8'><style id='Re1x8'><dir id='Re1x8'><q id='Re1x8'></q></dir></style></legend>

                    <tfoot id='Re1x8'></tfoot>

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

                          <tbody id='Re1x8'></tbody>