Hello,
Arrays in c# are 0 based that means that the first entry has an index of 0 and the last entry has an index of n-1.
There is a mistake in your code, you start by counting the number of lines and then create an array that size.
The issue is that you increment the counter by 1 just after creating the array.
string[] ListLines = new string[counter];
counter++;
So what happens next when you iterate the array is that you try to access the element "n" but the array stops at "n-1"
for (i = 0; i < counter; i++)
{
if (comboBox1.Text == ListLines[i])
{
urunkodu = Convert.ToUInt32(ListProductCodeFileLines[i]);
}
}
Basically you are reading an element that does not exist. This throws an exception index out of bounds because "n" is bigger that "n-1"
To fix this just remove the useless
counter++;
and your code will work fine.
Valery.