1.3. Alternative Forms of the Main() Function

In the rest of this chapter we'll explore the predefined elements of the C# language as we implement a small program called WordCount. WordCount opens a user-specified text file and calculates the number of occurrences of each word within the file. The results are sorted in dictionary order and written to an output file. In addition, the program supports two command-line options:

  1. -t causes the program to turn a trace facility on; by default, tracing is off.

  2. -s causes the program to calculate and report the amount of time it takes to read the file, process the words, and write the results; by default, timings are not reported.

Our first task in Main() is to access the command-line arguments passed in ...

Get C# Primer: A Practical Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.