本文整理匯總了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));
}
示例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));
}
示例3: Simple
public void Simple()
{
var bag1 = new Bag<int>();
var bag2 = SerializeUtil.BinarySerializeDeserialize(bag1);
Assert.AreNotSame(bag1, bag2);
Assert.IsTrue(bag1.Equals(bag2));
}
示例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));
}
示例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));
}
示例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));
}
示例7: Null
public void Null()
{
var bag1 = new Bag<int>();
bag1.Equals(null);
}
示例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));
}