ZengCode.Com (The Thai Php Framework)  


Home   Download   Manual   About us    

Facebook   


MAIN MENU
News
Php Tips
Android Programming
Design Pattern By PHP
C# using Linq น่าใช้จริงๆ
C# Tips & Technique
C# Design Pattern
Linux Quick Tips
Java & JavaScript Tips
Database & SQL
ZengCode Framework Guide
Zeng Code Code
Programming
IPhone (Tips and Trick)

Download เอกสารที่น่าสนใจ

     Prototype Pattern  (2010-03-15)

Protype pattern is a pattern for produce new objects from a instance, of the same class, basically clonning objects.
For implement prototype pattern in c#, class must implement ICloneable interface ขออนุญาติไม่แปรนะครับ กัวจะแปลแล้วเข้าใจยากหนักกว่าเดิม

 namespace Prototype
{

public class MyPrototype : ICloneable
{
  public String myName;

  public MyPrototype(String myName)
  {
    this.myName = myName;
  }

  public object Clone()
  {
    MyPrototype newObj = new MyPrototype(this.myName);
    newObj.myName = this.myName;
    return newObj;
  }

}//class
}//Prototype

 การเรียกใช้นะครับ

 

 
            MyPrototype obj1 = new MyPrototype("Chiwa Kantawong");

            MyPrototype obj2 = (MyPrototype) obj1.Clone();

            MessageBox.Show(obj1.myName + " <===> " + obj2.myName);

 


Comment
Name
Comment
Security CodeCAPTCHA Image

easy tracking
avis car rental discount code

This page took 0.234510 seconds to load.