How to read lines from a text file in C#

1 Answer

0 votes
using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            foreach (string line in File.ReadLines("d:\\test.txt"))
            {
                Console.WriteLine(line);
            }
        }
    }
}

/*
run:
   
Text File Line one
Text File Line two
Text File Line three

*/


answered Mar 12, 2015 by avibootz

Related questions

1 answer 180 views
1 answer 106 views
2 answers 250 views
1 answer 191 views
2 answers 262 views
1 answer 248 views
...