You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
713 B
27 lines
713 B
using System;
|
|
using System.Configuration;
|
|
using System.Collections.Specialized;
|
|
|
|
namespace ConsoleConfig
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
string sAttr;
|
|
|
|
// Read a particular key from the config file
|
|
sAttr = ConfigurationManager.AppSettings.Get("Key0");
|
|
Console.WriteLine("The value of Key0: " + sAttr);
|
|
|
|
// Read all the keys from the config file
|
|
NameValueCollection sAll;
|
|
sAll = ConfigurationManager.AppSettings;
|
|
|
|
foreach (string s in sAll.AllKeys)
|
|
Console.WriteLine("Key: " + s + " Value: " + sAll.Get(s));
|
|
Console.ReadLine();
|
|
}
|
|
}
|
|
}
|