Gets the appSettings section data for the current application's default configuration.
| C# | Visual Basic |
public static NameValueCollection AppSettings { get; }
Public Shared ReadOnly Property AppSettings As NameValueCollection Get
Returns a NameValueCollection object that contains the contents of the appSettings section for the current application's configuration.
The following code example shows how to use the AppSettings property.
CopyVB.NET
CopyC#
' Show how to use AppSettings. Shared Sub DisplayAppSettings() ' Get the AppSettings collection. Dim appSettings As NameValueCollection = ConfigurationManager.AppSettings Dim keys As String() = appSettings.AllKeys Debug.WriteLine() Debug.WriteLine("Application appSettings:") ' Loop to get key/value pairs. Dim i As Integer For i = 0 To appSettings.Count Debug.WriteLine("#{0} Name: {1} Value: {2}", i, keys(i), appSettings(i)) Next i End Sub 'DisplayAppSettings
// Show how to use AppSettings. static void DisplayAppSettings() { // Get the AppSettings collection. NameValueCollection appSettings = ConfigurationManager.AppSettings; string[] keys = appSettings.AllKeys; Debug.WriteLine(); Debug.WriteLine("Application appSettings:"); // Loop to get key/value pairs. for (int i = 0; i < appSettings.Count; i++) Debug.WriteLine("#{0} Name: {1} Value: {2}", i, keys[i], appSettings[i]); }