I have the following code below:
List<string> group = new List<string>();
List<int> groupInNumber = new List<int>();
Dictionary<string, List<string>> dicMyMap = new Dictionary<string, List<string>>();
Dictionary<string, int[]> a = new Dictionary<string, int[]>();
Dictionary<string, string[]> b = new Dictionary<string, string[]>();
private void SetData(out ExpandableListViewAdapter mAdapter)
{
int[] currentStatus = a["currentStatus"];
string[] statusDesc = b["description"];
int[] ticketID = a["ticketID"];
foreach (int s in currentStatus)
{
if (s == 1)
{
group.Add(statusDesc[0]);
}
else if (s == 2)
{
group.Add(statusDesc[1]);
}
else if (s == 3)
{
group.Add(statusDesc[2]);
}
else if (s == 4)
{
group.Add(statusDesc[3]);
}
else if (s == 5)
{
group.Add(statusDesc[4]);
}
else if (s == 6)
{
group.Add(statusDesc[5]);
}
else if (s == 7)
{
group.Add(statusDesc[6]);
}
else if (s == 8)
{
group.Add(statusDesc[7]);
}
else if (s == 9)
{
group.Add(statusDesc[8]);
}
else if (s == 10)
{
group.Add(statusDesc[9]);
}
}
for (int p = 0; p <= ticketID.Count(); p++)
{
groupInNumber.Add(ticketID[p]);
}
List<string> ticket = new List<string>();
for (int z = 0; z <= ticketID.Count(); z++)
{
string tix = ticketID[z].ToString();
ticket.Add(tix);
dicMyMap.Add(groupInNumber[z].ToString(), ticket);
ticket.Remove(tix);
}
mAdapter = new ExpandableListViewAdapter(this, group, dicMyMap);
}
The error occurs here, groupInNumber.Add(ticketID[p]);
What I don't understand is why the index is outside the bounds when 0
should be referring to the first value inside the array. I tried counting the items in int[] ticketID = a["ticketID"];
, isn't null, returned 39
(number of items in the array).