下面是一个浅拷贝的例子:
using System;
namespace Prototype_Shallow{
//因为我们在FCL里面已经有这样的接口所以我们就不定义新的Prototype了
public class ConcretePrototype1 : ICloneable{
private int m_ID;
public int ID{
get{
return this.m_ID;
}
}
public ConcretePrototype1(int id){
this.m_ID = id;
}
public object Clone(){
return this.MemberwiseClone();
}
}
public class ConcretePrototype2 : ICloneable{
private int m_ID;
public int ID
{
get
{
return this.m_ID;
}
}
public ConcretePrototype2(int id){
this.m_ID = id;
}
public object Clone(){
return this.MemberwiseClone();
}
}
}[@more@]