Implicit calling of the parameterless base-class constructor - CSharp Custom Type

CSharp examples for Custom Type:Inheritance

Introduction

If a constructor in a subclass omits the base keyword, the base type's parameterless constructor is implicitly called:

public class BaseClass
{
  public int X;
  public BaseClass() { X = 1; }
}

public class Subclass : BaseClass
{
  public Subclass() { Console.WriteLine (X); }  // 1
}

Related Tutorials