Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            InvitationCard obj1 = new InvitationCard();

            obj1.To      = "Sanjeev";
            obj1.Title   = "Birthday celebration";
            obj1.Content = "Please come to the party";
            obj1.SendBy  = "Sanjay";
            obj1.Date    = Convert.ToDateTime(DateTime.Now.ToShortDateString());
            //Here our first object has created.
            InvitationCard[] objList  = new InvitationCard[5];
            string[]         nameList = { "Sanjeev", "Shyam", "Hari", "Tapan", "Saroj" };
            int i = 0;

            foreach (string name in nameList)
            {
                objList[i]    = obj1.CloneMe(obj1);
                objList[i].To = nameList[i];
                i++;
            }

            //Print all invitation card here.
            foreach (InvitationCard obj in objList)
            {
                Console.WriteLine("To: " + obj.To);
                Console.WriteLine("Title: " + obj.Title);
                Console.WriteLine("Content: " + obj.Content);
                Console.WriteLine("Send By: " + obj.SendBy);
                Console.WriteLine("Date: " + obj.Date);
            }
            Console.ReadLine();
        }
Ejemplo n.º 2
0
 public InvitationCard CloneMe(InvitationCard obj)
 {
     return((InvitationCard)this.MemberwiseClone());
 }