本文整理汇总了C#中Computer.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Computer.Clone方法的具体用法?C# Computer.Clone怎么用?C# Computer.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Computer
的用法示例。
在下文中一共展示了Computer.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MemberwiseCloneTest
public void MemberwiseCloneTest()
{
var gpu = new GraphicsCard
{
AmountOfRam = 4,
GpuFrequency = 1.1m
};
var computer = new Computer
{
AmountOfCores = 4,
AmountOfRam = 32,
CpuFrequency = 3.4m,
DriveType = "ssd",
Gpu = gpu
};
var computer2 = (Computer)computer.Clone();
Assert.AreNotSame(computer2, computer);
Assert.AreNotSame(computer2.AmountOfCores, computer.AmountOfCores);
Assert.AreNotSame(computer2.AmountOfRam, computer.AmountOfRam);
Assert.AreNotSame(computer2.CpuFrequency, computer.CpuFrequency);
Assert.AreSame(computer2.DriveType, computer.DriveType);
Assert.AreEqual(computer2.Gpu.AmountOfRam, computer.Gpu.AmountOfRam);
Assert.AreEqual(computer2.Gpu.GpuFrequency, computer.Gpu.GpuFrequency);
computer.Gpu.AmountOfRam = 8;
Assert.AreNotEqual(computer2.Gpu.AmountOfRam, computer.Gpu.AmountOfRam);
}