本文整理汇总了C#中Sphere.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Sphere.Clone方法的具体用法?C# Sphere.Clone怎么用?C# Sphere.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sphere
的用法示例。
在下文中一共展示了Sphere.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: boxingButton_Click
private void boxingButton_Click(object sender, EventArgs e)
{
boxingListBox.Items.Add("Creating box...");
Box box = new Box(5, 10, 15);
boxingListBox.Items.Add("Cloning box as newBox...");
Box newBox = box.Clone();
boxingListBox.Items.Add("Do box and newBox reference same object? " + ReferenceEquals(box, newBox));
boxingListBox.Items.Add("Setting box to null...");
box = null;
boxingListBox.Items.Add("Is box null? " + (box == null));
boxingListBox.Items.Add("Is newBox null? " + (newBox == null));
boxingListBox.Items.Add("Volume : " + newBox.Volume());
boxingListBox.Items.Add("");
boxingListBox.Items.Add("Creating squareBox...");
SquareBox squareBox = new SquareBox(20);
// Additional Project code
squareBox.Dimension = 25;
int numberOfDimensions = SquareBox.Dimensions;
string volumeCalculation = SquareBox.VolumeCalcuation();
// end
SquareBox newSquareBox = squareBox.Reference();
boxingListBox.Items.Add("Do squareBox and newSquareBox reference same object? " + ReferenceEquals(squareBox, newSquareBox));
boxingListBox.Items.Add("Setting squareBox to null...");
squareBox = null;
boxingListBox.Items.Add("Is squarebox null? " + (squareBox == null));
boxingListBox.Items.Add("Is newSquareBox null? " + (newSquareBox == null));
// Additional Project code
boxingListBox.Items.Add("Are the dimensions equal to 25? " + (numberOfDimensions == 25) + " Actual: " + numberOfDimensions);
boxingListBox.Items.Add("What is the formula used for volume? " + volumeCalculation);
// End
boxingListBox.Items.Add("");
//Sphere code
boxingListBox.Items.Add("Creating sphere...");
Sphere sphere = new Sphere(5);
boxingListBox.Items.Add("Cloning sphere as newSphere...");
Sphere newSphere = sphere.Clone();
boxingListBox.Items.Add("do sphere and newSphere reference same object? " + ReferenceEquals(sphere, newSphere));
boxingListBox.Items.Add("Setting sphere to null...");
sphere = null;
boxingListBox.Items.Add("Is sphere null? " + (sphere == null));
boxingListBox.Items.Add("Is newSphere null? " + (newSphere == null));
boxingListBox.Items.Add("Volume: " + newSphere.Volume());
boxingListBox.Items.Add("What formula is used for sphere volume calculation? " + Sphere.SphereVolumeCalcuation());
}