4
Reply

base method

George George

George George

Oct 29 2008 9:42 PM
3.1k

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)