Well the .Count()
Methods of all Lists or Arrays start at 1, while a Index in the IT world always will start at 0. So at the very end, your count will reach a number that won't be in your index.
So try the suggestion of BviLLe_Kid and subtract 1.
EDIT
Okay forget that. I think that was a brainlag. But I think deleting this answer won't be necessary since I can tell that BviLLe_Kid suggestion is wrong.
SCIENCE
static void Main(string[] args)
{
List<string> tmpList = new List<string>();
for (int i = 0; i < 10; i++)
{
Debug.WriteLine("List Item No" + i);
tmpList.Add("Item " + i);
}
Debug.WriteLine("_____________");
Debug.WriteLine("List Count: " +tmpList.Count());
Debug.WriteLine("_____________");
for (int i = 0; i < tmpList.Count(); i++)
{
Debug.WriteLine(tmpList[i]);
}
}
Debug:
List Item No0
List Item No1
List Item No2
List Item No3
List Item No4
List Item No5
List Item No6
List Item No7
List Item No8
List Item No9
List Count: 10
Item 0
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9