Answers

Question and Answer:

  Home  C# (Sharp) Programming Language

⟩ What is the syntax for calling an overloaded constructor within a constructor (this() and constructorname() does not compile)?

The syntax for calling another constructor is as follows:

class B

{

B(int i)

{ }

}

class C : B

{

C() : base(5) // call base constructor B(5)

{ }

C(int i) : this() // call C()

{ }

public static void Main() {}

}

 169 views

More Questions for you: