Assembly : System.Configuration (dans system.configuration.dll)
SyntaxePublic Shared ReadOnly Property AppSettings As NameValueCollection
Dim value As NameValueCollection value = ConfigurationManager.AppSettings
public static NameValueCollection AppSettings { get; }
public: static property NameValueCollection^ AppSettings { NameValueCollection^ get (); }
/** @property */ public static NameValueCollection get_AppSettings ()
public static function get AppSettings () : NameValueCollection
Valeur de la propriété
Retourne un objet NameValueCollection contenant le contenu de l'objet AppSettingsSection pour la configuration par défaut de l'application actuelle.
Exceptions| Type d'exception | Condition |
|---|---|
| Impossible de récupérer un objet NameValueCollection avec les données de paramètres d'application. |
NotesUn objet AppSettingsSection contient le contenu de la section appSettings du fichier de configuration.
ExempleL'exemple de code suivant montre comment obtenir un paramètre d'application nommé à l'aide de la propriété AppSettings.
' Get appSettings. Shared Sub GetAppSettings() ' Get the appSettings. Dim appSettings As NameValueCollection = _ ConfigurationManager.AppSettings ' Get the collection enumerator. Dim appSettingsEnum As IEnumerator = _ appSettings.Keys.GetEnumerator() ' Loop through the collection and ' display the appSettings key, value pairs. Dim i As Integer = 0 While appSettingsEnum.MoveNext() Dim key As String = appSettings.Keys(i) Console.WriteLine("Name: {0} Value: {1}", _ key, appSettings(key)) i += 1 End While End Sub 'GetAppSettings
// Get appSettings. static void GetAppSettings() { // Get the appSettings. NameValueCollection appSettings = ConfigurationManager.AppSettings; // Get the collection enumerator. IEnumerator appSettingsEnum = appSettings.Keys.GetEnumerator(); // Loop through the collection and // display the appSettings key, value pairs. int i = 0; Console.WriteLine("App settings."); while (appSettingsEnum.MoveNext()) { string key = appSettings.Keys[i]; Console.WriteLine("Name: {0} Value: {1}", key, appSettings[key]); i += 1; } }
Plates-formesWindows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Édition Media Center, Windows XP Professionnel Édition x64, Windows XP SP2, Windows XP Starter Edition
Le .NET Framework ne prend pas en charge toutes les versions de chaque plate-forme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise.
Outils (masquer)
S'enregistrer
Liste des Membres
Qui est en ligne?
FAQ