I am getting an index out of range error, when I initialize the TValue to 10. So the elements should exist.
if (!sportsDictionary.ContainsKey(sports.Team))
{
sportsDictionary.Add(sports.Team, new List(10));
}
else
{
sportsDictionary[sports.Team][Team.sportsId] = sports;
//Error: index out of range above
}
David SmithPosted Jul 31, 2016, 4:25 AM
{
if (sportsDictionary[sportsObject.Team].Count < sportsObject.Index)
{
int resize = sportsObject.Index - sportsDictionary[Sports.Team].Count;
for (int i = 0; i <= resize; i++)
{
sportsDictionary[Sports.Team].Add(new SportsObject());
}
}
sportsDictionary[Sports.Team].Insert(waypoint.Index, sportsObject);
}
David SmithPosted Jul 31, 2016, 4:24 AM
Joginder BangerPosted Jul 31, 2016, 12:58 AM