The source code to get the environment variables using Environment class is given below. The given program is compiled and executed successfully.
using System;
using System.Collections;
class Sample
{
//Entry point of Program
static public void Main()
{
IDictionary evVars = Environment.GetEnvironmentVariables();
foreach (DictionaryEntry eVar in evVars)
{
Console.WriteLine("{0}:{1}", eVar.Key, eVar.Value);
}
}
}
Program:
The source code to get the environment variables using Environment class is given below. The given program is compiled and executed successfully.
Output: