.NET – When using the default constructor instantiated class, do it also call the base class constructor?

Does anyone know what C# behaves? Are all .NET languages ​​the same?
Yes-if you do not explicitly call the base class constructor, it will be in any constructor in the derived class This happens.

class Base
{
Base(){}
Base(int i){}< br />}

class Derived: Base
{
Derived(bool x) {} // calls Base.Base()
}
< br />class Derived2: Base
{
Derived2(): base(10) {} // calls Base.Base(int)
}

Does anyone know what the behavior of C# is? Are all .NET languages ​​the same?

Yes-if you don’t explicitly call the base class constructor, this will happen in any constructor in the derived class.

class Base
{
Base(){}
Base(int i){}
}

class Derived: Base
{
Derived(bool x) {} // calls Base.Base()
}

class Derived2: Base
{
Derived2(): base(10) {} // calls Base.Base(int)
}

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 237 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.