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(); }
if (lineItems[1] == "t2")Index was outside the bounds of the array. How do i solve this???