示例#1
0
 /*Copy Constructor*/
 //The constructor which takes a parameter of the class type is called a copy constructor.
 //This constructor is used to copy one object data into another object.
 //The main purpose of the copy constructor is to initialize a new object (instance) with
 //the values of an existing object (instance).
 public Constructors(Constructors tempobj)
 {
     this.eid     = tempobj.eid;
     this.age     = tempobj.age;
     this.name    = tempobj.name;
     this.address = tempobj.address;
 }
示例#2
0
        static void Main()
        {
            //If base class constructor is declared private below line will throw error
            Constructors e1 = new Constructors();
            Constructors e2 = new Constructors(e1);

            e1.Display();
            e2.Display();
            Console.ReadLine();
        }