ConfigurationManager.AppSettings Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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

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

static member AppSettings : NameValueCollection with 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.

Exception Condition

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" ?>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    <add key="Setting1" value="May 5, 2014"/>
    <add key="Setting2" value="May 6, 2014"/>

.NET Framework
Available since 2.0
Return to top