當前位置: 首頁>>代碼示例>>C#>>正文


C# Bag.Equals方法代碼示例

本文整理匯總了C#中Bag.Equals方法的典型用法代碼示例。如果您正苦於以下問題:C# Bag.Equals方法的具體用法?C# Bag.Equals怎麽用?C# Bag.Equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Bag的用法示例。


在下文中一共展示了Bag.Equals方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Simple

        public void Simple()
        {
            var bag1 = new Bag<string>();
            var bag2 = GetTestBag();

            var resultBag = bag1 * bag2;

            Assert.IsTrue(resultBag.Equals(bag1));

            bag1.Add("50", 2);

            var shouldBe = new Bag<string>();

            resultBag = bag1 * bag2;

            Assert.IsTrue(shouldBe.Equals(resultBag));

            bag1.Add("2", 2);

            shouldBe.Add("2", 2);

            resultBag = bag1 * bag2;

            Assert.IsTrue(shouldBe.Equals(resultBag));
        }
開發者ID:havok,項目名稱:ngenerics,代碼行數:25,代碼來源:Intersection.cs

示例2: Interface

        public void Interface()
        {
            var bag1 = new Bag<string>();
            var bag2 = GetTestBag();

            var resultBag = (Bag<string>)((IBag<string>)bag1).Intersection(bag2);

            Assert.IsTrue(resultBag.Equals(bag1));

            bag1.Add("50", 2);

            var shouldBe = new Bag<string>();

            resultBag = (Bag<string>)((IBag<string>)bag1).Intersection(bag2);

            Assert.IsTrue(shouldBe.Equals(resultBag));

            bag1.Add("2", 2);

            shouldBe.Add("2", 2);

            resultBag = (Bag<string>)((IBag<string>)bag1).Intersection(bag2);

            Assert.IsTrue(shouldBe.Equals(resultBag));
        }
開發者ID:havok,項目名稱:ngenerics,代碼行數:25,代碼來源:Intersection.cs

示例3: Simple

        public void Simple()
        {
            var bag1 = new Bag<int>();
            var bag2 = SerializeUtil.BinarySerializeDeserialize(bag1);

            Assert.AreNotSame(bag1, bag2);
            Assert.IsTrue(bag1.Equals(bag2));
        }
開發者ID:GTuritto,項目名稱:ngenerics,代碼行數:8,代碼來源:Serializable.cs

示例4: Interface

        public void Interface()
        {
            var bag1 = new Bag<int>();
            var bag2 = new Bag<int>();

            bag1.Add(2, 2);
            bag1.Add(3, 3);
            bag1.Add(4, 5);

            bag2.Add(3, 2);
            bag2.Add(4, 3);
            bag2.Add(5, 2);

            var shouldBe = new Bag<int> { { 2, 2 }, { 3, 5 }, { 4, 8 }, { 5, 2 } };

            var resultBag = (Bag<int>)((IBag<int>)bag1).Union(bag2);

            Assert.IsTrue(shouldBe.Equals(resultBag));

            resultBag = (Bag<int>)((IBag<int>)bag2).Union(bag1);

            Assert.IsTrue(shouldBe.Equals(resultBag));
        }
開發者ID:havok,項目名稱:ngenerics,代碼行數:23,代碼來源:Union.cs

示例5: Simple

        public void Simple()
        {
            var bag1 = new Bag<int>();
            var bag2 = new Bag<int>();

            bag1.Add(2, 2);
            bag1.Add(3, 3);
            bag1.Add(4, 5);

            bag2.Add(3, 2);
            bag2.Add(4, 3);
            bag2.Add(5, 2);
            bag2.Add(6, 2);

            var shouldBe = new Bag<int> { { 2, 2 }, { 3, 5 }, { 4, 8 }, { 5, 2 }, { 6, 2 } };

            var resultBag = bag1 + bag2;

            Assert.IsTrue(shouldBe.Equals(resultBag));

            resultBag = bag2 + bag1;

            Assert.IsTrue(shouldBe.Equals(resultBag));
        }
開發者ID:havok,項目名稱:ngenerics,代碼行數:24,代碼來源:Union.cs

示例6: Simple

        public void Simple()
        {
            var bag1 = new Bag<int>();
            var bag2 = new Bag<int>();

            Assert.IsFalse(bag1.Equals(null));

            Assert.IsTrue(bag1.Equals(bag2));
            Assert.IsTrue(bag2.Equals(bag1));

            bag2.Add(5);

            Assert.IsFalse(bag1.Equals(bag2));
            Assert.IsFalse(bag2.Equals(bag1));

            bag1.Add(5);

            Assert.IsTrue(bag1.Equals(bag2));
            Assert.IsTrue(bag2.Equals(bag1));

            // Add 6 now so that the count is the same
            bag1.Add(5);
            bag2.Add(6);
            Assert.IsFalse(bag1.Equals(bag2));
            Assert.IsFalse(bag2.Equals(bag1));

            bag1.Remove(5, 1);
            bag2.Remove(6);

            Assert.IsTrue(bag1.Equals(bag2));
            Assert.IsTrue(bag2.Equals(bag1));

            bag2.Add(6);

            Assert.IsFalse(bag1.Equals(bag2));
            Assert.IsFalse(bag2.Equals(bag1));

            bag1.Add(7);

            Assert.IsFalse(bag1.Equals(bag2));
            Assert.IsFalse(bag2.Equals(bag1));
        }
開發者ID:GTuritto,項目名稱:ngenerics,代碼行數:42,代碼來源:IsEqual.cs

示例7: Null

 public void Null()
 {
     var bag1 = new Bag<int>();
     bag1.Equals(null);
 }
開發者ID:GTuritto,項目名稱:ngenerics,代碼行數:5,代碼來源:IsEqual.cs

示例8: EqualsExample

        public void EqualsExample()
        {
            var bag1 = new Bag<string> {"cat", "dog", "canary"};

            var bag2 = new Bag<string> {"cat", "dog", "canary"};

            // bag1 is "Equal" to bag2
            Assert.IsTrue(bag1.Equals(bag2));
        }
開發者ID:havok,項目名稱:ngenerics,代碼行數:9,代碼來源:BagExamples.cs


注:本文中的Bag.Equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。