I am new to c#, I try to check if array with a customized class could work. As you see in my code, First Try is OK, but Second Try is NG. Thanks a lot if someone show me a way to solve it.
static void Main(string[] args)
{
#First Try OK
string[] a = new string[2];
a[0] = "Jordan";
a[1] = "Pippen";
Console.WriteLine(String.Join(",", a));
#Second Try NG
player[] b = new player[2];
b[0].name = "Jordan"; ==> Object reference not set to an instance of an object
b[1].name = "Pippen";
Console.WriteLine(String.Join(",", b));
}
class player
{
public string name;
}
I except I can know more detail about array concept.