Dar*_*rov 23
var specificValue = ConfigurationManager.AppSettings["specificKey"];
if (!string.IsNullOrEmpty(specificValue))
{
// Use the value
}
Run Code Online (Sandbox Code Playgroud)
但如果您只想检查存在,您还可以:
if (ConfigurationManager.AppSettings.AllKeys.Contains("specificKey"))
{
// the config file contains the specific key
}
Run Code Online (Sandbox Code Playgroud)