本文整理汇总了C#中Bag.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Bag.Clone方法的具体用法?C# Bag.Clone怎么用?C# Bag.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bag
的用法示例。
在下文中一共展示了Bag.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Overloading_Shown
private void Overloading_Shown(object sender, EventArgs e)
{
string lastName = "Lastname";
int age = 21;
float dollaz = 310.12F;
long centz = 31012L;
_myBag.Add(age);
_myBag.Add(lastName);
_myBag.Add(dollaz);
_myBag.Add(centz);
Bag _temporaryBag = new Bag();
_temporaryBag.Add("Second Bag String");
_temporaryBag.Add(100);
_myBag += _temporaryBag;
foreach (object contents in _myBag.Items)
{
outputListBox.Items.Add(contents.ToString());
}
Bag clonedBag;
int itemsInClone = _myBag.Clone(out clonedBag);
outputListBox.Items.Add("");
foreach (object contents in clonedBag.Items)
{
outputListBox.Items.Add(contents.ToString());
}
outputListBox.Items.Add("Cloned count: " + itemsInClone);
_myBag -= _temporaryBag;
outputListBox.Items.Add("");
outputListBox.Items.Add("Items in permanent bag after minus operator");
foreach (object contents in _myBag.Items)
{
outputListBox.Items.Add(contents.ToString());
}
outputListBox.Items.Add("Count of items after minus operator: " + _myBag.Items.Count());
}