I have written C# codes that make use of 2d arrays. Here are the codes:
class HelloWorld
{
static void Main(string[] args)
{
Person[,] _personArray = new Person[3,3];
int ages = _personArray[1,1].age;
Console.WriteLine(ages.ToString());
Console.ReadKey();
}
}
public class Person
{
public int age = 21;
}
However, it gives me an exception that says:
"Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at HelloWorldApplication.HelloWorld.Main (System.String[] args) [0x00000] in :0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object at HelloWorldApplication.HelloWorld.Main (System.String[] args) [0x00000] in :0 "
Can anyone please help me and tell me what is wrong with my codes? Your help will be appreciated :)