Interviewer And Interviewee Guide

C# (Sharp) Programming Language Interview Question:

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

Submitted by: Administrator
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() {}
}
Submitted by: Administrator

Read Online C# (Sharp) Programming Language Job Interview Questions And Answers
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.