当前位置: 首页>>代码示例>>C#>>正文


C# Sphere.Clone方法代码示例

本文整理汇总了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());
        }
开发者ID:etokrug,项目名称:CSharpProjects,代码行数:46,代码来源:Boxing.cs


注:本文中的Sphere.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。