title: C# how to convert File.ReadLines into string array?
body: <p>The question that I have is regarding converting the process of reading lines from a text file into an array instead of just reading it.</p>
  
  <p>The error in my codes appear at <code>string[] lines = File.ReadLines("c:\\file.txt");</code> with cannot implicity convert....</p>
  
  <p>Can someone please advise on the codes to save the results in an array format? I've placed the ReadAllLines code which is able to save the results in an array too. Thanks!</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Diagnostics;
  using System.IO;
  
  namespace Testing
  {
  class Analysis
  {
      static void Main()
      {
          string[] lines = File.ReadLines("c:\\file.txt");
  
          foreach (string r in lines)
          {
              Console.WriteLine("-- {0}", r);
          }
  
          // Keep the console window open in debug mode.
          Console.WriteLine("Press any key to exit.");
          System.Console.ReadKey();
      }
  }
  }
  </code></pre>
  
  <p>ReadAllLines Codes:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Diagnostics;
  using System.IO;
  
  namespace Testing
  {
  class ReadFromFile
  {
      static void Main()
      {
          string[] lines = System.IO.File.ReadAllLines
          (@"C:\Users\Public\TestFolder\WriteLines2.txt");
  
          System.Console.WriteLine("Contents of writeLines2.txt =:");
          foreach (string line in lines)
          {
              Console.WriteLine("\t" + line);
          }
  
          // Keep the console window open in debug mode.
          Console.WriteLine("Press any key to exit.");
          System.Console.ReadKey();
      }
  }
  }
  </code></pre>