SYSTEM空间有ICONEALBE接口。。。因为其太常用。
1 /* 2 * Created by SharpDevelop. 3 * User: home 4 * Date: 2013/4/21 5 * Time: 22:20 6 * 7 * To change this template use Tools | Options | Coding | Edit Standard Headers. 8 */ 9 using System; 10 11 namespace Resume 12 { 13 class Program 14 { 15 public static void Main(string[] args) 16 { 17 Resume a = new Resume("大鸟"); 18 a.SetPersonalInfo("男", "24"); 19 a.SetWorkExperience("1998-2000","国务院外事办"); 20 21 Resume b = (Resume)a.Clone(); 22 b.SetPersonalInfo("男", "26"); 23 b.SetWorkExperience("2000-2003","香港回归事务所"); 24 25 Resume c = (Resume)a.Clone(); 26 c.SetPersonalInfo("男", "28"); 27 c.SetWorkExperience("2005-2008","华盛顿亚洲战略中心"); 28 29 30 a.Display(); 31 b.Display(); 32 c.Display(); 33 34 35 Console.Write("Press any key to continue . . . "); 36 Console.ReadKey(true); 37 } 38 } 39 class WorkExperience : ICloneable 40 { 41 private string workDate; 42 public string WorkDate 43 { 44 get { return workDate; } 45 set { workDate = value; } 46 } 47 private string company; 48 public string Company 49 { 50 get { return company; } 51 set { company = value; } 52 } 53 public Object Clone() 54 { 55 return (object)this.MemberwiseClone(); 56 } 57 } 58 class Resume : ICloneable 59 { 60 private string name; 61 private string sex; 62 private string age; 63 private WorkExperience work; 64 65 public Resume(string name) 66 { 67 this.name = name; 68 work = new WorkExperience(); 69 } 70 private Resume(WorkExperience work) 71 { 72 this.work = (WorkExperience)work.Clone(); 73 } 74 75 public void SetPersonalInfo(string sex, string age) 76 { 77 this.sex = sex; 78 this.age = age; 79 } 80 public void SetWorkExperience(string workDate, string company) 81 { 82 work.WorkDate = workDate; 83 work.Company = company; 84 } 85 86 public void Display() 87 { 88 Console.WriteLine("{0} {1} {2}", name, sex, age); 89 Console.WriteLine("工作经历: {0} {1}", work.WorkDate, work.Company); 90 } 91 public object Clone() 92 { 93 Resume obj = new Resume(this.work); 94 obj.name = this.name; 95 obj.sex = this.sex; 96 obj.age = this.age; 97 return obj; 98 } 99 } 100 }