Valerie Meunier

Valerie Meunier

  • NA
  • 693
  • 84.1k

SystemNullReferenceExceptions error

Dec 24 2022 11:50 AM

Hi

I get this error: SystemNullReferenceExceptions  at line in bold.

Thanks for help.

V

using System;
class MyClass
{
    public static void Main()
    {
        TeamScore[] teams = new TeamScore[4];
        teams[0].TeamName = "A";
        teams[1].TeamName = "B";
        teams[2].TeamName = "C";
        teams[3].TeamName = "D";
    }
}

class TeamScore
{
    public string TeamName { get; set; }
    public int Score { get; set; }
}

 


Answers (2)