Thursday, 29 September 2016

Copy Constructor


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

Effortless Slider Styling: Create Custom CSS Range Inputs in Seconds

What is Range Input  range in HTML ?                   Range Input  is a control that is present from very early version of HTML. Input Rang...