When creating an object is very time consuming or complex in some way than we can just make the clone of existing object. This is called Prototype pattern.
public class PersonData : ICloneable
{
public Object clone()
{
try
{
return this.MemberwiseClone();
}
catch(Exception e)
{
Console.Writeline(e.Message);
return null;
}
}
}
public class PersonData : ICloneable
{
public Object clone()
{
try
{
return this.MemberwiseClone();
}
catch(Exception e)
{
Console.Writeline(e.Message);
return null;
}
}
}
No comments:
Post a Comment