Here is a little code snippet i have written recently for type free variable assignment from config’s appSettings node using c#

public static void ReadFromConfig<T>(string key, ref T obj)
{
    string value = System.Configuration.ConfigurationManager.AppSettings[key];
    if (!string.IsNullOrEmpty(value)) obj = (T)System.Convert.ChangeType(value, typeof(T));
}

The usage is simple as itself.

// initialize a variable with a default value
int foo = 9;

// change the value of foo if any value assigned to it from config
// otherwise do nothing

ReadFromConfig<int>("foosetting", ref foo); 

Hope, this helps…