1
Reply

Index was outside the bounds of the array.

scorpion  king

scorpion king

Apr 15 2010 3:32 PM
4k
 StreamReader sr = new StreamReader(inputFile); 
string[] allData = sr.ReadLine();
foreach (string line in allData)
{

string[] lineItems = line.Split(',');
if (lineItems[1] == "t2") // here i am getting the whole line into an array and then i can check whatever line i want with the [] and return appropriate result.
sb.AppendLine("2," + paramPath1);
else
sb.AppendLine("a," + paramPath1);


}
using (StreamWriter outfile =
new StreamWriter(outputFileName))
{
outfile.Write(sb.ToString());
outfile.Close();

}


In this code i am getting an error at
 if (lineItems[1] == "t2")
Index was outside the bounds of the array.
How do i solve this???


Answers (1)