Sample Input:
just a sample line
another sample line
first matching Order line
not a match
...here's a Order match
Order 123
foreach (var match in File.ReadLines(@"c:\LogFile.txt")
.Select((text, index) => new { text, lineNumber = index+ 1 })
.Where(x => x.text.Contains("Order ")))
{
Console.WriteLine("{0}: {1}", match.lineNumber, match.text);
}
Output:
3: first matching Order line
5: ...here's a Order match
6: Order 123
No comments:
Post a Comment