AppSettingsSection.Settings Property


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

Gets a collection of key/value pairs that contains application settings.

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

[ConfigurationPropertyAttribute("", IsDefaultCollection = true)]
public KeyValueConfigurationCollection Settings { get; }

Property Value

Type: System.Configuration.KeyValueConfigurationCollection

A collection of key/value pairs that contains the application settings from the configuration file.

The following example uses the Settings property to read the appSettings values.

   // This function shows how to read the key/value
   // pairs (settings collection)contained in the 
   // appSettings section.
   static void ReadAppSettings()

           // Get the configuration file.
           System.Configuration.Configuration config =

           // Get the appSettings section.
           System.Configuration.AppSettingsSection appSettings =

           // Get the auxiliary file name.
           Console.WriteLine("Auxiliary file: {0}", config.AppSettings.File);

           // Get the settings collection (key/value pairs).
           if (appSettings.Settings.Count != 0)
               foreach (string key in appSettings.Settings.AllKeys)
                   string value = appSettings.Settings[key].Value;
                   Console.WriteLine("Key: {0} Value: {1}", key, value);
               Console.WriteLine("The appSettings section is empty. Write first.");
       catch (Exception e)
           Console.WriteLine("Exception raised: {0}",

.NET Framework
Available since 2.0
Return to top