Home > DeveloperSection > Blogs > Copy Constructor in C#

Copy Constructor in C#


C# C# 
Ratings:
1 Comment(s)
 4489  View(s)
Rate this:

Copy Constructor in C#

This is the one type of constructor. A copy constructor creates an object by copying variables from another object.
for example
we pass one item object to the item constructor so that the new item object has the same value as the old one.

copy constructor defined as :
public Student(Student stud)
{
name=stud.name;
age=stud.age;
}

the copy constuctor is invoked by instaintiating an object of type Student and passing it the object to be copied.
example
Student stud1=new Student(stud2);
Now, stud1 is a copy of stud2.


Copy constructor in c#.

By Awadhendra Tiwari on   5 years ago

Hi....

Its very useful blog.


Don't want to miss updates? Please click the below button!

Follow MindStick