This one always catches me out. There are a few different ways to read settings in from a .config file. The confusion for me occurs when reading from certain sections and from config files other than ones for the currently running application. The easiest example is reading settings from the currently running application, from within it's own code. You can access the AppSettings Section <configuration><appSettings> <add key="hostname1" value="localhost"/><add key="hostname2" value="othername"/></appSettings></configuration> using: NameValueCollection appSettings = ConfigurationManager.AppSettings; foreach(string key in appSettings.AllKeys) Console.WriteLine(key + " " + appSettings[key]); So now you've all the keys in the AppSettings section i.e. "hostname1" and "hostname" and all their values accessed with appSettings[key] . Note: First you must add a reference to 'Sys...
Layman explanations of Software coding and configuration techniques. With example code where possible.