What does the "base" syntax mean?

c#, syntax

Solution

The `:base` syntax is a way for a derived type to chain to a constructor on the base class which accepts the specified argument. If omitted the compiler will silently attempt to bind to a base class constructor which accepts 0 arguments.

class Parent {
  protected Parent(int id) { } 
}

class Child1 : Parent {
  internal Child1() { 
    // Doesn't compile.  Parent doesn't have a parameterless constructor and 
    // hence the implicit :base() won't work
  }
}

class Child2 : Parent {
  internal Child2() : base(42) { 
    // Works great
  }
}

There is also the `:this` syntax which allows chaining to constructors in the same type with a specified argument list

Problem

Can somone please tell me what does the syntax below means? ``` public ScopeCanvas(Context context, IAttributeSet attrs) : base(context, attrs) { } ``` I mean what is `method(argument) : base(argument) {}` ?? P.S This is a constructor of a class.

Original source

Related problems