Free mag vol1 | Page 147

CHAPTER 3  CORE C# PROGRAMMING CONSTRUCTS, PART I Table 3-1. Select Properties of System.Environment Property Meaning in Life ExitCode Gets or sets the exit code for the application Is64BitOperatingSystem Returns a bool to represent if the host machine is running a 64-bit OS MachineName Gets the name of the current machine NewLine Gets the newline symbol for the current environment SystemDirectory Returns the full path to the system directory UserName Returns the name of the user that started this application Version Returns a Version object that represents the version of the .NET platform  Source Code The SimpleCSharpApp project is located under the Chapter 3 subdirectory. The System.Console Class Almost all of the example applications created over the course of the initial chapters of this book make extensive use of the System.Console class. While it is true that a console user interface (CUI) is not as enticing as a graphical user interface (GUI) or web-application, restricting the early examples to console programs will allow us to keep focused on the syntax of C# and the core aspects of the .NET platform, rather than dealing with the complexities of building desktop GUIs or web sites. As its name implies, the Console class encapsulates input, output, and error-stream manipulations for console-based applications. Table 3-2 lists some (but definitely not all) members of interest. As you can see, the Console class does provide some members that can spice up a simple command-line application, such as the ability to change background and foreground colors and issue beep noises (in a variety of frequencies!). Table 3-2. Select Members of System.Console Member Meaning in Life Beep() This method forces the console to emit a beep of a specified frequency and duration. BackgroundColor ForegroundColor These properties set the background/foreground colors for the current output. They may be assigned any member of the ConsoleColor enumeration. 81