gpt4 book ai didi

c# - 将项目添加到字典返回 System.IndexOutOfRangeException : Index was outside the bounds of the array

转载 作者:太空宇宙 更新时间:2023-11-03 19:51:30 29 4
gpt4 key购买 nike

<分区>

我有下面的代码:

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);
}

错误发生在这里,groupInNumber.Add(ticketID[p]); 我不明白的是为什么当0应该是索引时却在边界之外引用数组中的第一个值。我尝试计算 int[] ticketID = a["ticketID"]; 中的项目,不为空,返回 39(数组中的项目数)。

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com