public class test
{
int _IntValue;
string _StringValue;
public test(int i)
{
_IntValue=i;
}
public test(int i, string s)
{
//here it is necessary to execute code from the first constructor
_StringValue = s + _IntValue;
}
}
public test(int i, string s) : this(i)
{
_StringValue = s + _IntValue;
}
Guessed myself. Works similar to the transfer of control to the constructor of the parent, but instead base - this.
public class test
{
int _IntValue;
string _StringValue;
public test(int i)
{
_IntValue = i;
}
public test(int i, string s):this(i)
{
_StringValue = s + _IntValue;
}
}
public class test
{
int _IntValue;
string _StringValue;
public test(int i)
{
_IntValue=i;
}
public test(int i, string s)
{
//here it is necessary to execute code from the first constructor
this.test(i);
_StringValue = s + _IntValue;
}
}
Find more questions by tags C#