I've seen a million answers about StreamReader and how to write to a file, but NOTHING about how to read a file, do a mathematical process on what is read and write the ANSWER to that process in another file. I need this for homework, please. My code in C#, .NET 2008 is as follows:
private void calcButton_Click(object sender, EventArgs e)
{
using (StreamReader sr = new StreamReader("output.txt"))
{
double score;
while ((score = sr.ReadLine()) != null)
{
score = score + score;
++count;
averageScore = (double)score / count;
}
Console.WriteLine(@"C:\output.txt", averageScore, true);
}
}
and I am getting the error "Cannot implicitly convert type 'string' to 'double' " on sr.ReadLine code. What do I write and where do I write it so that I can get a number and do the calculations?? If I can get this done, then I can start on an Address Book application for my final... Thanks in advance...