How do I loop over lines from a TextReader source
?
I tried
foreach (var line in source)
But got the error
foreach statement cannot operate on variables of type 'System.IO.TextReader' because 'System.IO.TextReader' does not contain a public definition for 'GetEnumerator'
string line;
while ((line = myTextReader.ReadLine()) != null)
{
DoSomethingWith(line);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With