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 155 views
155 views asked Mar 11, 2017 by avibootz
1 answer 174 views
1 answer 215 views
1 answer 196 views
196 views asked Jan 20, 2017 by avibootz
1 answer 177 views
177 views asked Mar 12, 2015 by avibootz
2 answers 267 views
...