var objTypeIndex = from u in context.sistema_DocType_Index where u.docTypeId == id select u.indexId;
indexIds = objTypeIndex.ToList();
int count = indexIds.Count();
string[] names = new string[] {};
int i = 0;
foreach (int indexId in indexIds)
{
//resgata nome do indice e armazena em um array
string strIndiceID = indexId.ToString();
int indiceID = Convert.ToInt32(strIndiceID);
var objIndexName = from u in context.sistema_Indexes where u.id == indiceID select u.idName;
name =
names[i] = objIndexName.First();
i++;
}
This line above the last:
names[i] = objIndexName.First();
gives the following error:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
I know what that means.. I just can´t figure out why.
Replace
By
And instead of
Use
Then, you will be able to get your array as follow: