【发布时间】:2017-10-18 17:46:32
【问题描述】:
我正在使用 C# 7 读取文本文件中的所有行,如下所示:
using (StreamReader reader = File.OpenText(file)) {
String line;
while ((line = reader.ReadLine()) != null) {
}
}
对于每一行,我还需要获取行号。
StreamReader 似乎没有获取行号的方法。
最好的方法是什么?
【问题讨论】:
-
我不明白什么吗?为什么不能自己数一数呢?
标签: c#