Reading in a text file and using the data.

  • Thread starter Thread starter Paul Lemelle
  • Start date Start date
P

Paul Lemelle

I am trying to read in a text file then use the data in the file.

I know how to read a file wiht the System.IO namespace:

FileRead fr = new StreamReader("data.txt");
Console.Writeline(fr.Readline());

or

StreamReader fr = File.OpenText("Data.txt");
string buffer = null
While ((buffer = re.Readline()) !+ null)
{
Console.Writeline(buffer);
}
fr.close;

But how do I use the data after it is read? In short, I would like to
store the data in a varabile.

Paul
 
Just assign it to a variable instead of dumping it to the console.

Before you ask how to do that, read up on the assigment operator (=).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top