How to read all lines at once from a text file in C#

1 Answer

0 votes
using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] lines = File.ReadAllLines("d:\\test.txt");

            foreach (string line in lines)
                Console.WriteLine(line);
        }
    }
}

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


answered Mar 11, 2015 by avibootz

Related questions

1 answer 179 views
1 answer 226 views
2 answers 278 views
1 answer 565 views
2 answers 346 views
1 answer 195 views
195 views asked Mar 12, 2015 by avibootz
1 answer 228 views
...