C Method for reading all lines of a file into an array

  • 2021-07-09 09:05:59
  • OfStack

This article illustrates how C # reads all the lines of a file into an array. Share it for your reference. The specific implementation method is as follows:


using System;
namespace PlayingAround {
 class ReadAll {
  public static void Main(string[] args) {
   string[] lines = System.IO.File.ReadAllLines(@"C:\t1");
   Console.Out.WriteLine("contents = " + lines.Length);
   Console.In.ReadLine();
  }
 }
}

I hope this article is helpful to everyone's C # programming.


Related articles: