Although all of the programs in this book will use it, the statement
using System;
at the start of the first example program is not technically needed. It is, however, a valuable convenience. The reason it’s not necessary is that in C# you can always fully qualify a name with the namespace to which it belongs. For example, the line
Console.WriteLine("A simple C# program.");
can be rewritten as
System.Console.WriteLine("A simple C# program.");
Thus, the first example could be recoded as shown here:
// This version does not include the using System statement. class Example { // A C# program begins with a call to Main(). public static void Main() { // Here, Console.WriteLine is fully qualified. System.Console.WriteLine("A simple C# program."); } }
Since it is quite tedious to always specify the System namespace whenever a member of that namespace is used, most C# programmers include the using System statement at the top of their programs, as will all of the programs in this book. It is important to understand, however, that you can explicitly qualify a name with its namespace if needed.