以下代码报错误:“Resum.Program.Resume”不实现接口成员“System.ICloneable.Clone()”
恳求大侠们帮忙,谢谢了。using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Resum
{
class Program
{
class Resume : ICloneable
{
private string name;
private string sex;
private string age;
private string timearea;
private string company; public Resume(string name)
{
this.name = name;
} public void SetPersonalInfo(string sex, string age)
{
this.sex = sex;
this.age = age;
} public void SetWorkExperience(string timearea, string company)
{
this.timearea = timearea;
this.company = company;
} public void Display()
{
Console.WriteLine("{0},{1},{2}", name, sex, age);
Console.WriteLine("工作经历:{0},{1}", timearea, company);
} public object clone()
{
return (object)this.MemberwiseClone();
//Console.WriteLine("成功实现接口");
}
}
static void Main(string[] args)
{
Resume a = new Resume("tony");
a.SetPersonalInfo("man", "12");
a.SetWorkExperience("1999-2008", "12"); Resume b = (Resume)a.clone;
b.SetWorkExperience("2008-2009", "1234");
Resume c = (Resume)a.clone;
c.SetPersonalInfo("nan","24"); a.Display();
b.Display();
c.Display(); Console.Read();
}
}
}
恳求大侠们帮忙,谢谢了。using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Resum
{
class Program
{
class Resume : ICloneable
{
private string name;
private string sex;
private string age;
private string timearea;
private string company; public Resume(string name)
{
this.name = name;
} public void SetPersonalInfo(string sex, string age)
{
this.sex = sex;
this.age = age;
} public void SetWorkExperience(string timearea, string company)
{
this.timearea = timearea;
this.company = company;
} public void Display()
{
Console.WriteLine("{0},{1},{2}", name, sex, age);
Console.WriteLine("工作经历:{0},{1}", timearea, company);
} public object clone()
{
return (object)this.MemberwiseClone();
//Console.WriteLine("成功实现接口");
}
}
static void Main(string[] args)
{
Resume a = new Resume("tony");
a.SetPersonalInfo("man", "12");
a.SetWorkExperience("1999-2008", "12"); Resume b = (Resume)a.clone;
b.SetWorkExperience("2008-2009", "1234");
Resume c = (Resume)a.clone;
c.SetPersonalInfo("nan","24"); a.Display();
b.Display();
c.Display(); Console.Read();
}
}
}
注意加红色的地方
在2008下编译通过 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Resum {
class Program {
class Resume : ICloneable {
private string name;
private string sex;
private string age;
private string timearea;
private string company; public Resume(string name) {
this.name = name;
} public void SetPersonalInfo(string sex, string age) {
this.sex = sex;
this.age = age;
} public void SetWorkExperience(string timearea, string company) {
this.timearea = timearea;
this.company = company;
} public void Display() {
Console.WriteLine("{0},{1},{2}", name, sex, age);
Console.WriteLine("工作经历:{0},{1}", timearea, company);
} public object Clone() {
return (object)this.MemberwiseClone();
//Console.WriteLine("成功实现接口");
}
}
static void Main(string[] args) {
Resume a = new Resume("tony");
a.SetPersonalInfo("man", "12");
a.SetWorkExperience("1999-2008", "12"); Resume b = (Resume)(a.Clone()); b.SetWorkExperience("2008-2009", "1234"); Resume c = (Resume)(a.Clone()); c.SetPersonalInfo("nan", "24"); a.Display();
b.Display();
c.Display(); Console.Read();
}
}}
调用的时候 有小括号的
不要忘记 结贴