C#: 得到系统中的环境变量(源代码)
using System;
using System.Collections;
namespace Project1
{
class ListSystemProperties
{
static void Main()
{
System.Console.WriteLine("\tKey\t\t\tValue");
foreach (DictionaryEntry enValue in Environment.GetEnvironmentVariables())
{
string key = enValue.Key.ToString();
string value = enValue.Value.ToString();
System.Console.WriteLine("\t"+key);
System.Console.WriteLine("\t\t" + value);
}
}
}
}
using System.Collections;
namespace Project1
{
class ListSystemProperties
{
static void Main()
{
System.Console.WriteLine("\tKey\t\t\tValue");
foreach (DictionaryEntry enValue in Environment.GetEnvironmentVariables())
{
string key = enValue.Key.ToString();
string value = enValue.Value.ToString();
System.Console.WriteLine("\t"+key);
System.Console.WriteLine("\t\t" + value);
}
}
}
}