如何循环从TextReader的线路?线路、TextReader

2023-09-03 04:03:01 作者:冷态度

如何在从的TextReader

我试过

 的foreach(源VAR行)
 

但得到的错误

  

foreach语句无法在类型System.IO.TextReader变量操作,因为System.IO.TextReader不包含GetEnumerator的

一个公共定义 解决方案

 串线;
而((行= myTextReader.ReadLine())!= NULL)
{
    DoSomethingWith(线);
}
 

请问如何进行长距离低压供电线路引接

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);
}