
What
is the need for Prototype Pattern
|
Here is
a code sample to demonstrate it:
abstract class prototypeClass {
private int member;
public prototypeClass(int member) {
this.member = member;
}
public void getMember() {
Console.WriteLine(Member value = {0}, member);
}
public abstract prototypeClass clonePrototype();
}
class actualClass : prototypeClass {
public actualClass(int member):base(member) { }
public override prototypeClass clonePrototype() {
prototypeClass obj = (prototypeClass) this.MemberwiseClone();
return obj;
}
}
class testClass {
actualClass sampleObj = new actualClass(10);
actualClass clonedObj = (actualClass) sampleObj.clonePrototype();
clonedObj.getMember();
}
_______________________________________________________________________
FREE Subscription
Subscribe
to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.
Note
: We never rent, trade, or sell my email lists to
anyone.
We assure that your privacy is respected
and protected.
Visit .NET Programming Tutorial Homepage
______________________________________________________