In C#, it seems the following method works which will allow you to
call Streamreader.readline() and then access that very same line in the next loop.
string line;
double score = 0;
count = 0;
while ((line = sr.ReadLine()) != null)
{
score += double.Parse (line);
count++;
}
averageScore = (double)inValue / count;
This does not work in vb.net though, even with all the converters which I tried.
this one completely bombs out and throws “page not found”
http://converter.telerik.com/
this one:
http://www.developerfusion.com/tools/convert/csharp-to-vb/?batchId=3356dd81-818a-43d1-8c23-be584e40d15e
results in :
Dim line As String
Dim score As Double = 0
count = 0
While (InlineAssignHelper(line, sr.ReadLine())) IsNot Nothing
score += Double.Parse(line)
count += 1
End While
averageScore = CDbl(inValue) / count
where InlineAssignHelper is something I dont have.
If you have the filename, instead of just a stream, you can use
System.IO.File.ReadLinesfor the neatest way:Or use LINQ: