Zack Zack - 1 month ago 10
C# Question

Can anyone explain me this specific inheritance syntax?

Can someone explain me this specific syntax in C# ?
I guess this has something to do with Inheritance but I just don't get the syntax with "this" and "new" keywords

public A() : this (new B(), new C())
{
//Method body
}


Thanks,
Zack

Edit :
I mean, I know this and new keywords but I'm new in C# programming and didn't know this syntax
Thanks all for your answers :-)

Answer

It is not inheritance, it calls another constructor of the same class:

public class A
{
    public A() : this(new B(), new C())
    {
    }    

    public A(B b, C c)
    {
    }
}

See microsoft documentation Using constructors