Programming Example 11: File Input
This program illustrates some important concepts related to file input. As you
study this code, look for the following important pieces of code:
- The declaration of the StreamWriter object.
- Reading each line of the file into a string.
- Checking to make sure that the string just read is not null.
- Using the Split method to break up the elements of data on each line.
- Using the Parse method to convert a string into an integer.
- Reading until the a null string is returned from the ReadLine( ) method.
- Converting a time in minutes and seconds into seconds.
- Sorting times and runner's names
- breaking a time back up into minutes and seconds.
To run this program, be sure that the file included here is stored in the
same place as the executable. Study the code in this program carefully, and then look at the program's output.
The data file for this program is
The problem statement for this program is located
The example program is located
here. An executable of this program can be found