Прототип (Prototype)

Інколи клонувати об'єкт і змінити в ньому один параметр є швидшим, за його створення з нуля

    interface IFigure

    {

        IFigure Clone();

        void GetInfo();

    }

    class Rectangle : IFigure

    {

        int width;

        int height;

        public Rectangle(int w, int h)

        {

            width = w;

            height = h;

        }

        public IFigure Clone()

        {

            return new Rectangle(this.width, this.height);

        }

        public void GetInfo()

        {

            Console.WriteLine("Rectangle: h=" + height + " w=" + width);

        }

    }

        static void Main(string[] args)

        {

            IFigure figure = new Rectangle(30, 40);

            IFigure clonedFigure = figure.Clone();

            figure.GetInfo();

            clonedFigure.GetInfo();           

            Console.Read();

        }