What is Constructor Chaining

If you ask the question that can we call constructor from another constructor then I will say yes we can. Calling constructor from another constructor is known as constructor chaining . Constructor Chaining can be done by the keyword this and base. Here we discuss on this keyword and will discuss base keyword in the article constructor with inheritance.

Example of Constructor Chaining

		
public class Class1
{
    public Class1(): this(10)
    { 
    
    }
    public Class1(int x)
    { 
    

    
    }

}

In this way constructor will call another constructor.

Note:-static constructor cannot be chained. And a public constructor can access a private constructor with the help of constructor chaining.