0

I would like to know if I can access the constructor of the base class in its derived classes in C#. If yes please let me know how could we make it. Thanks in advance.

Ahammad Fekri
  • 31
  • 2
  • 5
  • 3
    Possible duplicate of [Calling the base constructor in C#](http://stackoverflow.com/questions/12051/calling-the-base-constructor-in-c-sharp) – Shawn Mehan Oct 10 '15 at 18:03

1 Answers1

1

You can call the base class constructor as part of the execution of the derived class constructor

public MyBase
{
    public MyBase() { }
}

public Derived
{
    public Derived() : base() { }
}

When using this pattern, you are said to be using the base class initializer.

For more background, see the base keyword and instance constructors on MSDN.

Eric J.
  • 147,927
  • 63
  • 340
  • 553