Есть некий класс Figure:
Синтаксис:
Используется csharp
class Figure : MonoBehaviour
{
private readonly byte index;
private readonly Transform position;
public Figure(in byte index, in Transform position) //конструктор класса
{
this.index = index;
this.position = position;
}
}
{
private readonly byte index;
private readonly Transform position;
public Figure(in byte index, in Transform position) //конструктор класса
{
this.index = index;
this.position = position;
}
}
И есть другой класс, который содержит Figure:
Синтаксис:
Используется csharp
class otherClass : MonoBehaviour
{
private Figure[] figures;
public void InitializeFigures(in byte count, in Transform thisTransform)
{
figures = new Figure[count];
for (byte i = 0; i < count; i++)
{
Debug.Log("1) figures[i] = " + figures[i]); //Вывод - "1) figures[i] = "
figures[i] = new Figure(i, transform);
Debug.Log("2) figures[i] = " + figures[i]); //Вывод - "2) figures[i] = null" //Почему null
}
}
}
{
private Figure[] figures;
public void InitializeFigures(in byte count, in Transform thisTransform)
{
figures = new Figure[count];
for (byte i = 0; i < count; i++)
{
Debug.Log("1) figures[i] = " + figures[i]); //Вывод - "1) figures[i] = "
figures[i] = new Figure(i, transform);
Debug.Log("2) figures[i] = " + figures[i]); //Вывод - "2) figures[i] = null" //Почему null
}
}
}
Почему во втором выводе может быть null, если я создаю новый экземпляр класса Figure?