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() {} }
Raj
Oct 19th, 2006
wrongit has have "{}" now after the call to the base class public c1() : base() { }(atleast in .net 2.0 )
zeroKelvin71493
Jun 18th, 2007
You need to make the constructors public ... then it will compile and run.
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() {}
}
Related Answered Questions
Related Open Questions