Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
<code class="cs"> struct SomeStruct
{
private int _i;
private double _d;
public SomeStruct(int i)
{
this = new SomeStruct();
_i = i;
// Поле _d инициализировано неявно!
}
}
</code> struct SomeStruct
{
private int _i;
private double _d;
public SomeStruct(int i)
: this()
{
// this в теле метода является ref SomeStruct
CreateOrUpdate(ref this);
}
public SomeStruct(double d)
{
// this() не вызывается, значит this является out SomeStruct:
Create(out this);
}
public static void CreateOrUpdate(ref SomeStruct str)
{
str = new SomeStruct();
}
public static void Create(out SomeStruct str)
{
str = new SomeStruct();
}
}
Структуры и конструкторы по умолчанию