C# Environment GetEnvironmentVariables()
Description
Environment GetEnvironmentVariables()
retrieves
all environment variable names and their values from the current process.
Syntax
Environment.GetEnvironmentVariables()
has the following syntax.
public static IDictionary GetEnvironmentVariables()
Returns
Environment.GetEnvironmentVariables()
method returns A dictionary that contains all environment variable names and their values;
otherwise, an empty dictionary if no environment variables are found.
Example
The following example demonstrates the GetEnvironmentVariables method.
//from w w w . j av a2 s . c om
using System;
using System.Collections;
class Sample
{
public static void Main()
{
IDictionary environmentVariables = Environment.GetEnvironmentVariables();
foreach (DictionaryEntry de in environmentVariables)
{
Console.WriteLine(" {0} = {1}", de.Key, de.Value);
}
}
}
The code above generates the following result.