Ok, im trying to make something but it isnt working out for me as well as i thought it would. Bassicly im trying to Add to a list within an custom class array, is this makes any sense. Here is some code to perhaps make it easier to understand:
public class pfft
{
public class Player
{
public string Name { get; set; }
public int br { get; set; }
}
public class team
{
public int totalbr { get; set; }
public List<Player> players { get; set; }
}
}
public pfft.team[] Teams;
public int tmcount = 4;
private void btn_team_Click(object sender, EventArgs e)
{
Teams = new pfft.team[tmcount]();
foreach(pfft.Player p in getallplayers())
{
Teams[0].players.Add(p);
}
}
This is bassicly all im doing, but when trying to add the player to the players list it crashes. Object reference not set to an instance of an object. The p it is trying to add does contain values, I checked that in the debugger I have also tried calling
Teams[0].players = new List<pfft.Player>();
but when i try that it will give the Nullexception at that part...