none
Constructor examples RRS feed

Answers

  • The program is terminating before you can see results.  Simply add a readline at end of program like below.

           static void Main(string[] args)
            {
    
                Car obj1 = new Car("BMW Sedan", 4545, 5000000);
    
                Car obj2 = new Car(obj1);
                Console.WriteLine("Car Name : {0}", obj2._nameofcar);
    
                Console.WriteLine("Car Number : {0}", obj2._carno);
                Console.WriteLine("Car Price : {0}", obj2._carprice);
    
                Console.ReadLine();
            }


    jdweng

    • Proposed as answer by chriga Sunday, November 24, 2013 9:47 PM
    • Marked as answer by Caillen Tuesday, December 3, 2013 9:33 AM
    Sunday, November 24, 2013 11:43 AM

All replies

  • The program is terminating before you can see results.  Simply add a readline at end of program like below.

           static void Main(string[] args)
            {
    
                Car obj1 = new Car("BMW Sedan", 4545, 5000000);
    
                Car obj2 = new Car(obj1);
                Console.WriteLine("Car Name : {0}", obj2._nameofcar);
    
                Console.WriteLine("Car Number : {0}", obj2._carno);
                Console.WriteLine("Car Price : {0}", obj2._carprice);
    
                Console.ReadLine();
            }


    jdweng

    • Proposed as answer by chriga Sunday, November 24, 2013 9:47 PM
    • Marked as answer by Caillen Tuesday, December 3, 2013 9:33 AM
    Sunday, November 24, 2013 11:43 AM
  • Ahh, thanks a lot :)) silly me, I added Console.ReadKey(); in a class. Cheers! :)
    Sunday, November 24, 2013 12:49 PM
  • What this "Copy Constructor" does is also more commonly known as "Cloning".


    Let's talk about MVVM: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2 Please mark post as helpfull and answers respectively.

    Sunday, November 24, 2013 11:36 PM