Skip to content

Passing parameters for multiple constructors usng single obj

harry code

Asked Mar 12, 2018, 1:13 AM EDT1 answer
Share
LinkedInX
Hi,
I want to pass parameters to multiple constructors of different class with the help of a single instance of child class.Can i call them???
My code looks like this:
 
 
C#
class parent1
{
public parent1()
{
}
}

class parent2
{
public parent2():parent1
{
}
}

class parent3:parent2
{
public parent3()
{
}
}

class child
{
static void Main()
{
 child c=new child(10,20,30);
}
}

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    sorry..This is my code...Forgot to enter paramaters
     
    C#
    class parent1
    {
    public parent1(int a)
    {
    }
    }
    class parent2
    {
    public parent2(int b):parent1
    {
    }
    }
    class parent3:parent2
    {
    public parent3(int c)
    {
    }
    }
    class child:parent3
    {
    static void Main()
    {
    child c=new child(10,20,30);
    }
    }
    0