我正在使用流阅读器来读取文本文件,然后使用Linq来检索信息
String fileContent = prodFileStreamReader.ReadToEnd();
var mydata = from con in fileContent.Split('$').Select(x => x.Trim())
where !String.IsNullOrEmpty(con)
select new BaseSegment
{
dataID = con.Substring(0, con.IndexOf('#')),
dataElms = con.Split('#').ToArray(),
dataCon = con,
lineNumber =
};
Run Code Online (Sandbox Code Playgroud)
我还想得到行号.我尝试使用索引,但我无法做到.如何查询获取索引并将其分配给lineNumber?