constructor call another constructor

L

Le, Thanh-Nhan

Hi,
How can I from constructor of a class call another constructor? As following
(as in Java):


public class Test
{

public Test()
{
this("", "");
}

public Test(String p_sErrorMessage)
{
this(p_sErrorMessage, "");
}

public Test(String p_sErrorMessage, String p_sHelp)
{
txtMessage.Text = p_sErrorMessage;
txtHelp.Text = p_sHinweis;
}

}

Thanks
Nhan
 
D

David Browne

Le said:
Hi,
How can I from constructor of a class call another constructor? As
following
(as in Java):

C# uses the C++ style of contstructor invocation:

public class Test
{
public Test() :this("", "")
{
}
public Test(String p_sErrorMessage) :this(p_sErrorMessage, "")
{
}
public Test(String p_sErrorMessage, String p_sHelp)
{
txtMessage.Text = p_sErrorMessage;
txtHelp.Text = p_sHinweis;
}
}

David
 
L

Le, Thanh-Nhan

Thanks
Nhan

David Browne said:
C# uses the C++ style of contstructor invocation:

public class Test
{
public Test() :this("", "")
{
}
public Test(String p_sErrorMessage) :this(p_sErrorMessage, "")
{
}
public Test(String p_sErrorMessage, String p_sHelp)
{
txtMessage.Text = p_sErrorMessage;
txtHelp.Text = p_sHinweis;
}
}

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top