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 Shared ReadOnly Property AppSettings As NameValueCollection
Dim value As NameValueCollection

value = ConfigurationManager.AppSettings

/** @property */
public static NameValueCollection get_AppSettings ()

public static function get AppSettings () : NameValueCollection

Not applicable.

Property Value

Returns a NameValueCollection object that contains the contents of the AppSettingsSection object for the current application's default configuration.

Exception typeCondition


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 code example shows how to use the AppSettings property.

' Show how to use AppSettings.
Shared Sub DisplayAppSettings() 
    ' Get the AppSettings collection.
    Dim appSettings As NameValueCollection = _
    Dim keys As String() = appSettings.AllKeys
    Console.WriteLine("Application appSettings:")
    ' Loop to get key/value pairs.
    Dim i As Integer
    For i = 0 To appSettings.Count
        Console.WriteLine("#{0} Name: {1} Value: {2}", i, _
        keys(i), appSettings(i))
    Next i

End Sub 'DisplayAppSettings

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions