C Sharp (C#) - Inheritance
Which of the following is the correct syntax to chain constructors in C#?
: this(parameters) after the constructor signature to call another constructor in the same class.: this(5) which correctly calls another constructor with an int parameter. public MyClass() : this() { } calls itself recursively causing error. public MyClass() : base() { } calls base class constructor, not chaining. public MyClass() { this(); } tries to call constructor inside body, which is invalid.: this(...) [OK]15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions