Answer to Question #150982 in C# for Paudraig Dennehy

Question #150982
how do you add a text file to the command line arguments, read it into the code and then convert it to an array
1
Expert's answer
2020-12-14T04:58:28-0500
using System;

using System.IO;




namespace ConsoleApp1

{

  class Program

  {

    static void Main(string[] args)

    {

      string file = args[0];




      string text = File.ReadAllText(file);




      string[] array = text.Split(' ');




      foreach (string str in array)

      {

        Console.WriteLine(str);

      }

    }

  }

}


example.exe text.txt


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS