i wanted to get value by text file
the text file has two-columns integer data and they are split by blank such like "82 10"
the file has many rows, at least 100 rows
anyway, the error is occurred when my program is processing in final row !
for example, the final part of text file is
12 15
15 16
20 45
then the console is show
12 15
15 16
and NullReferenceException error is occurred
I know meaning of error, my question is not what is NULLRef error but why it is occured although I already put the condition in while sentences
here is my code
using System;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
StreamReader file = new StreamReader(@"E:\text.txt");
int tmpx = 0, tmpy = 0;
while (file.ReadLine() != null)
{
string[] component = file.ReadLine().Split(' ');
int.TryParse(component[0], out tmpx);
int.TryParse(component[1], out tmpy);
// Console.Write(file.ReadLine()+"\n");
Console.Write(tmpx + " " + tmpy +"\n");
}
}
}
}