Inherit Parent Constructor Behaviour

  • Thread starter Thread starter Xarky
  • Start date Start date
X

Xarky

Hi,
Having the following scenario:

public class Parent
{
private string Parent_name;

public Parent()
{
this.Parent_name = "";
}
}


public class Child : Parent
{
public Child()
{
// I need to inherit the behaviour of the parent constructor
// and
// and new behaiour
}
}

Can someone help me out.


Thanks in Advance
 
Xarky said:
public class Parent
{
private string Parent_name;

public Parent()
{
this.Parent_name = "";
}
}


public class Child : Parent
{
public Child()
{
// I need to inherit the behaviour of the parent constructor
// and
// and new behaiour
}
}

Can someone help me out.

In this case, you can just add the extra code in the Child's
parameterless constructor. The parameterless Parent constructor will be
called automatically.

See http://www.pobox.com/~skeet/csharp/constructors.html for more
information.
 
Back
Top