Problem:

  • Lots of configuration things can potentially change, and command line arguments are out of the question.

Solution:

Sample Code:

(:source lang=C#:)
// in the code
string mykey = System.Configuration.ConfigurationSettings.AppSettings ["Key1"];

// foobar.exe.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Key1" value="Kevin" />
</appSettings>
</configuration>

Note:

  • Apparently, this is now deprecated. Maybe should use ConfigurationManager API instead.

Related Links: