Answer the question
In order to leave comments, you need to log in
How to pass control to another constructor?
Let's say I have a class:
public class test
{
int _IntValue;
string _StringValue;
public test(int i)
{
_IntValue=i;
}
public test(int i, string s)
{
//тут надо бы выполнить код из первого конструктора
_StringValue = s + _IntValue;
}
}
Answer the question
In order to leave comments, you need to log in
public test(int i, string s) : this(i)
{
_StringValue = s + _IntValue;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question