C# Clone函数重写?

using System;
namespace Wrox.ProCSharp.Basic
{
class CloneTest
{
static void Main()
{
string[] names={"Lily","John","Ian"};
string[] namesClone=(string[])names.Clone(); 
namesClone[2]="June";
foreach(string name in names)
{
Console.WriteLine("{0}",name);

}
foreach(string name in namesClone)
{
Console.WriteLine("{0}",name);

}
Person Test=new Person("Lily",16);
Person TestClone=(Person)Test.Clone();
Test.age=19;
Console.WriteLine("{0},{1}",Test.name,Test.age);
Console.WriteLine("{0}{1}",TestClone.name,TestClone.age);

}

}

class Person
{
public string name;
public int age;
public Person(string name,int age)
{
this.name=name;
this.age=age;
}

}
}

编译提示perison类不包含Clone定义
1、是不是自定义类使用Clone函数就必须重写Clone函数?
2、应该如何改写

翻阅古今
浏览 727回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP