Copy Constructor : The feature is that , C# allow us to copy constructor .
Example 1
class myclass
{
// Copy constructor.
public myclass(myclass previousPerson)
{
Name = previousPerson.Name;
address = previousPerson.Age;
}
// Instance constructor.
public myclass(string name, int age)
{
Name = name;
address = age;
}
public string
address { get; set;
}
public string
Name { get; set;
}
}
Here myclass is
iniatialised , passing Name and address ,then the constructor is passed to
another constructor is passed during initialization .This behaviors is known as
copy constructor.
No comments:
Post a Comment