Categories

Oct 18, 2019 in C Sharp (C#)
Q: Explain Copy constructor in C#?

1 Answer

Oct 18, 2019
If the constructor contains the same class in the constructor parameter then it is called as copy constructor.

class MyClass

{

 public string prop1, prop2;

 public MyClass(string a, string b)

 {

 prop1 = a;

 prop2 = b;

 }

 

 public MyClass(MyClass myobj) // Copy Constructor

 {

 prop1 = myobj.prop1;

 prop2 = myobj.prop2;

 }

}
Click here to read more about C Sharp
Click here to read more about Insurance

Related questions

Madanswer
Jul 16, 2019 in C++
Oct 18, 2019 in C Sharp (C#)
Oct 18, 2019 in C Sharp (C#)
...