Enda Phelan

Enda Phelan

  • NA
  • 1
  • 1.5k

I would like to format this content read from a text file.

Apr 26 2013 3:05 PM
Here is the contents of the text file:

Darren O Grady, Manchester, 280

Aine Mc, East London, 500

Sean Jameson, Ireland, 600

David James, Germany, 250


And the following is my code that reads this information into the console application as is:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

//streamreader

using System.IO;


namespace Scoreboard

{

    class Program

    {

        static void Main(string[] args)

        {

            //

            // Read in a file line-by-line, and store it all in a List.

            //

            List<string> list = new List<string>();

            using (StreamReader reader = new StreamReader(@"h:\scores.txt"))

            {

                string line;

                while ((line = reader.ReadLine()) != null)

                {


                    list.Add(line); // Add to list.


                    Console.WriteLine(line); // Write to console.


                }

                Console.ReadLine();

            }

        }


    }

}

    





        






I would like it to be read in the following format:


 

 Player Name        Score         Citation

 


 Darren O Grady     Manchester    280

Aine Mc            East London   500

Sean Jameson       Ireland       600

David James        Germany       250

 

Average Score:     505

Top Player:     Sean Jameson



    





        





Answers (1)