Export (0) Print
Expand All

ConfigurationManager::AppSettings Property

Gets the AppSettingsSection data for the current application's default configuration.

Namespace:  System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)

public:
static property NameValueCollection^ AppSettings {
	NameValueCollection^ get ();
}

Property Value

Type: System.Collections.Specialized::NameValueCollection
Returns a NameValueCollection object that contains the contents of the AppSettingsSection object for the current application's default configuration.

ExceptionCondition
ConfigurationErrorsException

Could not retrieve a NameValueCollection object with the application settings data.

A AppSettingsSection object contains the contents of the configuration file's appSettings section.

The first example shows a simple console application that reads application settings, adds a new setting, and updates an existing setting.

No code example is currently available or this language may not be supported.

The previous example assumes your project has an App.config file as shown below.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  <appSettings>
    <add key="Setting1" value="May 5, 2014"/>
    <add key="Setting2" value="May 6, 2014"/>
  </appSettings>
</configuration>

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft