I liked codebender's answer, but needed it to work in C++/CLI. This is what I ended up with. There's no LINQ usage, but works.
generic <typename T> T MyClass::ReadAppSetting(String^ searchKey, T defaultValue) {
for each (String^ setting in ConfigurationManager::AppSettings->AllKeys) {
if (setting->Equals(searchKey)) { // if the key is in the app.config
try { // see if it can be converted
auto converter = TypeDescriptor::GetConverter((Type^)(T::typeid));
if (converter != nullptr) { return (T)converter->ConvertFromString(ConfigurationManager::AppSettings[searchKey]); }
} catch (Exception^ ex) {} // nothing to do
}
}
return defaultValue;
}