What am I doing wrong here?
I am trying to loop the lines and then loop the fields in each line. I am doing this because each line can have a different number of fields. Below is the code I am using but it is not looping the fields separately, it is just the array from the 1st loop.
StreamReader readFile = new StreamReader(Filename);
readFile.ReadLine();
while ((line = readFile.ReadLine()) != null)
{
for (int i = 0; i < line.Length; i++)
{
string[] field = new string[] { line.ToString() };
for (int x = 0; x < field.Length; x++)
{
string myfield;
myfield = field[x].ToString();
// do some processing here
}
}
}
readFile.Close();
New contributor
Robert Keith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.