Hello,
In the code below,how do I declare myLine as a public(global) variable? The problem is that I can't use the keyword "var".
public static IEnumerable<string> ReadLines(StreamReader reader)
{
while (!reader.EndOfStream)
{
yield return reader.ReadLine();
}
}
private void Filter1(string filename)
{
using(var writer = File.CreateText(Application.StartupPath + "\\temp\\test.txt"))
{
using (var reader = File.OpenText(filename))
{
int[] Ids = { 14652, 14653, 14654, 14655, 14656, 14657, 14658, 14659, 14660 };
var myLine = from line in ReadLines(reader)
where line.Length > 1
let id = int.Parse(line.Split('\t')[1])
where Ids.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 };
foreach (var id in myLine)
{
writer.WriteLine("Item Id = " + id.ItemId);
writer.WriteLine("Path = " + id.Path);
writer.WriteLine("\n");
}
}
}
}
I want to do it ,because I have to find a way to gain access to that ienumerable for later use.