How to read text file line by line in c#

1 Answer

0 votes
using System;
using System.IO;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;

            StreamReader file = new StreamReader("d:\\data.txt");
            while ((line = file.ReadLine()) != null)
                Console.WriteLine(line);

            file.Close();
        }
    }
}


/*
run:
     
java c c++ c# php
javascript
python

*/

 



answered Dec 23, 2016 by avibootz

Related questions

1 answer 213 views
213 views asked Jul 1, 2014 by avibootz
1 answer 214 views
1 answer 173 views
1 answer 174 views
174 views asked Apr 8, 2021 by avibootz
2 answers 327 views
327 views asked Jan 4, 2021 by avibootz
...