PROTOTYPE PATTERN

It creates new object from existing instance of an object.Let us see it by an example.

    class Program
    {
        static void Main(string[]   args)
        {
            Customer objcust1 = new Customer();
            Customer objcust2 = new Customer();
            objcust1.strcode = "one";
            objcust2 = objcust1.getClone();
            objcust2.strcode = "TWO";
            Console.WriteLine("objcust1" + objcust1.strcode);
            Console.WriteLine("objcust2" + objcust2.strcode);
            Console.ReadLine();
        }
    }
    class Customer
    {
        public string strcode = "";
        public Customer getClone()
        {
            return (Customer)this.MemberwiseClone();
        }
    }

The first object is cloned to get second object.Here in the below example the first object has strcode value as "one" and second object has strcode value as "two".Both objects are having different value. The final output will display first object value as "one" and second object value as "two".It uniquely displays the output of the two objects. Suppose if we doesnt clone second object ,we will have same value for second object also.That means both object will have value as "one".

Output: