1. Iterate the lines of the file
Copy the code The code is as follows:
public static IEnumerable ReadLines(string fileName)
{
using (TextReader reader = File.OpenText(fileName))
{
string line;
if (( line = reader.ReadLine()) != null)
static void Main()
{
foreach (string line in Iterator.ReadLines(" "))
Console.WriteLine. proceed Filter
Copy code
The code is as follows:
public static IEnumerable
where(IEnumerable predicate)
{ if (source == null || predicate == null)
{ throw new ArgumentNullException(); } WhereImplemeter(source, predicate); } private static IEnumerable WhereImplemeter(IEnumerable source, Predicate predicate) foreach (T item in source )
IEnumerable
lines = File.ReadAllLines(@"your file name");
Predicate predicate = delegate(string line)
return line .StartsWith("using" );
🎜>
}
http://www.bkjia.com/PHPjc/327537.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327537.htmlTechArticle1. The line copy code of the iterated file is as follows: public static IEnumerablestring ReadLines(string fileName) { using (TextReader reader = File.OpenText(fileName)) { string line; if (...