This documentation is archived and is not being maintained.

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 NameValueCollection AppSettings { 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.


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 following example shows how to use the AppSettings property. It is part of a larger example that is provided for the ConfigurationManager class.

// Get the AppSettings section.        
// This function uses the AppSettings property
// to read the appSettings configuration 
// section.
public static void ReadAppSettings()
    // Get the AppSettings section.
    NameValueCollection appSettings =

    // Get the AppSettings section elements.
    Console.WriteLine("Using AppSettings property.");
    Console.WriteLine("Application settings:");

    if (appSettings.Count == 0)
      Console.WriteLine("[ReadAppSettings: {0}]",
      "AppSettings is empty Use GetSection command first.");
    for (int i = 0; i < appSettings.Count; i++)
      Console.WriteLine("#{0} Key: {1} Value: {2}",
        i, appSettings.GetKey(i), appSettings[i]);
  catch (ConfigurationErrorsException e)
    Console.WriteLine("[ReadAppSettings: {0}]",

The example works with configuration elements that are similar to the ones illustrated in the following configuration file. These elements are generated the first time you run the example.

      <add key="NewKey0" value="Monday, March 30, 
           2009 1:36:33 PM" />
      <add key="NewKey1" value="Monday, March 30, 
           2009 1:36:40 PM" />

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.