Hi there,
Im trying to populate an object array in unity using C#, i declare the array like this:
Card[][] aCardGrid;
When I try to assign the card object to the array
aCardGrid*[j] = new Card();*
*```*
*<p>I get this error:</p>*
*<p>NullReferenceException: Object reference not set to an instance of an object*
*GameScript.Start () (at Assets/Scripts/GameScript.cs:29)</p>*
*<p>I tested the creation of the object and it's working fine, just get this error when i try to put it inside the array...</p>*
*<p>Anyone?</p>*
This code segment gives me the error Invalid rank specifier: expected ',' or ']' \Program.cs ConsoleApplication4
Adding this answer to support the reminder to fill the 3D array with nested for
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Foo f = new Foo();
Foo[][] myArray = new Foo[2][3];
}
}
class Foo
{
public int x;
public Foo()
{
x = 1;
}
}
}