G
Guest
Hi,
I am trying to retrieve values from a text document in this format:
NewProd(0,0) = "xy004125"
NewProd(0,1) = "myTitle"
NewProd(1,0) = "xy004136"
NewProd(1,1) = "anotehrTitle"
NewProd(2,0) = "xy004115"
NewProd(2,1) = "yetAnotherTitle"
and so on...
Eventually i am going to try and pull out the product number and title and
put them in a xml file, but for now, i just want to retrieve the first group
of digits and put them in an array for further processing.
The problem is i can't get past the blank line. I keep getting the all the
zeros and then get a "Index was outside the bounds of the array" message.
Heres my code:
using (StreamReader sr = new StreamReader("test.inc"))
{
string sLine;
while ((sLine = sr.ReadLine()) != null)
{
if (sLine != null)
{
int firstParans = sLine.IndexOf('(');
firstParans = firstParans + 1;
char firstDig = sLine[firstParans];
Console.WriteLine(firstDig);
}
}
}
output is:
0
0
and then the error message mention above.
What am i missing?
Thanks
I am trying to retrieve values from a text document in this format:
NewProd(0,0) = "xy004125"
NewProd(0,1) = "myTitle"
NewProd(1,0) = "xy004136"
NewProd(1,1) = "anotehrTitle"
NewProd(2,0) = "xy004115"
NewProd(2,1) = "yetAnotherTitle"
and so on...
Eventually i am going to try and pull out the product number and title and
put them in a xml file, but for now, i just want to retrieve the first group
of digits and put them in an array for further processing.
The problem is i can't get past the blank line. I keep getting the all the
zeros and then get a "Index was outside the bounds of the array" message.
Heres my code:
using (StreamReader sr = new StreamReader("test.inc"))
{
string sLine;
while ((sLine = sr.ReadLine()) != null)
{
if (sLine != null)
{
int firstParans = sLine.IndexOf('(');
firstParans = firstParans + 1;
char firstDig = sLine[firstParans];
Console.WriteLine(firstDig);
}
}
}
output is:
0
0
and then the error message mention above.
What am i missing?
Thanks