Configurationmanager. etettings attributes-go

Source: Internet
Author: User
Configurationmanager. deleettings attributes

Note: This attribute is added in. NET Framework 2.0.

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

Syntax Visual Basic (Declaration)
Public Shared ReadOnly Property AppSettings As NameValueCollection
Visual Basic (usage)
Dim value As NameValueCollectionvalue = ConfigurationManager.AppSettings
C #
public static NameValueCollection AppSettings { get; }
C ++
public:static property NameValueCollection^ AppSettings {    NameValueCollection^ get ();}
J #
/** @property */public static NameValueCollection get_AppSettings ()
JScript
public static function get AppSettings () : NameValueCollection

 

 

Attribute Value

Returns a namevaluecollection object that contains the default configuration of the current application.AppsettingssectionObject content. Exception

Exception type Condition

Configurationerrorsexception

Data Retrieval cannot be set using the applicationNamevaluecollectionObject.

Remarks

AppsettingssectionObjects that contain the configuration fileAppsettingsSection.

Example

The following code example demonstrates how to useAppsettingsProperty to get the application settings named.

Visual Basic
' 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 WhileEnd Sub 'GetAppSettings 
C #
// 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;    }}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.