I started learning C#, and I saw that in inheritance we do :
derivedClass(): base()
and then I noticed in another example the use of :
Constructor(): this(parameter)
which I didn't quite understand
my question is do the keywords that are used like this
Constructor() : Keyword
have a name ? and what are some of them, and there uses?
Thank you !
The specification refers to these as constructor-initializers, and lists this
and base
as valid. From the spec:
10.11.1 Constructor initializers
All instance constructors (except those for class object) implicitly include an invocation of another instance constructor immediately before the constructor-body. The constructor to implicitly invoke is determined by the constructor-initializer:
• An instance constructor initializer of the form
base
(argument-listopt) causes an instance constructor from the direct base class to be invoked. ...• An instance constructor initializer of the form
this
(argument-listopt) causes an instance constructor from the class itself to be invoked. ...