CSharp - Essential Types Environment class

Introduction

static System.Environment class provides a range of useful properties:

Item Properties
Files and foldersCurrentDirectory, SystemDirectory, CommandLine
Computer and operating system MachineName, ProcessorCount, OSVersion, NewLine
User logon UserName, UserInteractive, UserDomainName
Diagnostics TickCount, StackTrace, WorkingSet, Version

You can obtain additional folders by calling GetFolderPath.

You can access OS environment variables with the following three methods: GetEnvironmentVariable,GetEnvironmentVariables, and SetEnvironmentVariable.

ExitCode property sets the return code.

FailFast method terminates a program immediately without performing cleanup.

Demo

using System;
class MainClass/*from  ww  w.  jav a 2s .c  o  m*/
{
   public static void Main(string[] args)
   {

       Console.WriteLine(Environment.CurrentDirectory);

   }
}

Result

Exercise