Interacting with the Environment

Today’s programs don’t stand on their own. They often have to interact with the outside world in a variety of ways. While we explore I/O in Chapter 28, “Working with I/O,” one form of interaction is covered here: talking to “the environment.”

The concept of an environment is hardwired in the operating system. Every program has access to it, containing both global information as well as some information that’s specific to the program’s invocation (such as the command line used). In .NET, all this information is made available through the (static) class Environment.

Instead of giving a dump of what can be read in MSDN documentation, let’s limit ourselves to a few examples. First of all, here’s some general information ...

Get C# 5.0 Unleashed 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.