【发布时间】:2009-05-23 16:28:00
【问题描述】:
这是我的功能:
private IEnumerable<string> SeachItem(int[] ItemIds)
{
using (var reader = File.OpenText(Application.StartupPath + @"\temp\A_A.tmp"))
{
var myLine = from line in ReadLines(reader)
where line.Length > 1
let id = int.Parse(line.Split('\t')[1])
where ItemIds.Contains(id)
let m = Regex.Match(line, @"^\d+\t(\d+)\t.+?\t(item\\[^\t]+\.ddj)")
where m.Success == true
select new { Text = line, ItemId = id, Path = m.Groups[2].Value };
return myLine;
}
}
我收到一个编译错误,因为“myLine”不是 IEnumerable[string],而且我不知道如何编写 IEnumerable[Anonymous]
“无法将类型'System.Collections.Generic.IEnumerable[AnonymousType#1]'隐式转换为'System.Collections.Generic.IEnumerable[string]'”
【问题讨论】: