O'Reilly logo

.NET Common Language Runtime Unleashed by Kevin Burton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

System.Environment

Use this class to retrieve the following information:

  • Command-line arguments

  • Current directory

  • System directory

  • Exit codes

  • Machine name

  • Domain name

  • Username

  • Tick count

  • Newline character sequence

  • OS version

  • Environment variable settings

  • Contents of the call stack

  • Version of the CLR

  • Working set

Listing B.6 shows a sample program calling some of the environment methods and properties (environment.cs).

Listing B.6. Environment Example
 static void Main(string [] args) { Console.WriteLine("Command line: {0} ", Environment.CommandLine); Console.WriteLine("Directory: {0} ", Environment.CurrentDirectory); Console.WriteLine("Exit Code: {0} ", Environment.ExitCode); Console.WriteLine("Machine name: {0} ", Environment.MachineName); Console.Write("NewLine: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required