4
Answers

base method

George George

George George

16y
3.1k
1

Hello everyone,


I noticed in some code, in a derived class, the constructor will be written in a way like this, my question is whether it is good code to add base()? Because I think

- base() will be implicitly called for derived class constructor if we do not pass any parameters to base class;
- if we need to pass any parameters, I think we could declare in this way and pass parameter to base class in :base (parameters to base class constructor);
- so there is no need to declare in this way.

Any comments? Is my understanding correct?

[Code]
DerivedClassConstructor():base()
{
    // derived class constructor implementation
}
[/Code]


thanks in advance,
George

Answers (4)