How to count all 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)
        {
            int totalLine = File.ReadAllLines("d:\\test.txt").Length;

            Console.WriteLine(totalLine); // 3
        }
    }
}

/*
run:
   
3
 
*/


answered Mar 11, 2015 by avibootz

Related questions

1 answer 246 views
246 views asked Mar 11, 2017 by avibootz
1 answer 271 views
1 answer 319 views
1 answer 288 views
288 views asked Jan 20, 2017 by avibootz
1 answer 283 views
283 views asked Mar 12, 2015 by avibootz
2 answers 406 views
...