How to declare an array of objects in C#

后端 未结 7 437
春和景丽
春和景丽 2020-12-23 16:12

I have a very beginning C# question. Suppose I have a class called GameObject, and I want to create an array of GameObject entities. I could think

相关标签:
7条回答
  • 2020-12-23 16:52

    You are creating an array of null references. You should do something like:

    for (int i = 0; i < houses.Count; i++)
    {
        houses[i] = new GameObject();
    }
    
    0 讨论(0)
提交回复
热议问题