Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Retrieve application settings
//Credit goes to this blog post
//USAGE: int serverPort = GetAppSetting<int>("server_port");
public static T GetAppSetting<T>(string key)
if (ConfigurationManager.AppSettings.AllKeys.Contains(key))
return (T)System.Convert.ChangeType(ConfigurationManager.AppSettings[key],
typeof(T), CultureInfo.InvariantCulture);
return default(T);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.