I have a class Club which has a list _list as an argument, while 'Player' is another class ... I have this method for adding the club members, thas is implemented this way:
public void AddPlayer(Player p)
{
if(_list.Contains( p))
throw new Exception("The Player " + p.Name + " " + p.Surname + " is already a member of this club!");
_list.Add(p);
}
Now, when I do this in my main program:
Player p = new Player("Christiano", "Ronaldo", 1993);
Club club = new Club("ManUtd", coach);
club.AddPlayer(p);
It throws an exception that says that object reference is not set as an instance of an object.