Configuration.AppSettings 속성

정의

AppSettingsSection 개체에 적용되는 Configuration 개체 구성 섹션을 가져옵니다.

public:
 property System::Configuration::AppSettingsSection ^ AppSettings { System::Configuration::AppSettingsSection ^ get(); };
public System.Configuration.AppSettingsSection AppSettings { get; }
member this.AppSettings : System.Configuration.AppSettingsSection
Public ReadOnly Property AppSettings As AppSettingsSection

속성 값

AppSettingsSection 개체에 적용되는 appSettings 구성 섹션을 나타내는 Configuration 개체입니다.

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 AppSettings 속성입니다.

try
{
    AppSettingsSection appSettings =
        config.AppSettings as AppSettingsSection;
    Console.WriteLine("Section name: {0}",
            appSettings.SectionInformation.SectionName);

    // Get the AppSettings section elements.
    Console.WriteLine();
    Console.WriteLine("Using AppSettings property.");
    Console.WriteLine("Application settings:");
    // Get the KeyValueConfigurationCollection 
    // from the configuration.
    KeyValueConfigurationCollection settings =
      config.AppSettings.Settings;

    // Display each KeyValueConfigurationElement.
    foreach (KeyValueConfigurationElement keyValueElement in settings)
    {
        Console.WriteLine("Key: {0}", keyValueElement.Key);
        Console.WriteLine("Value: {0}", keyValueElement.Value);
        Console.WriteLine();
    }
}
catch (ConfigurationErrorsException e)
{
    Console.WriteLine("Using AppSettings property: {0}",
        e.ToString());
}
Try
    Dim appSettings As AppSettingsSection = TryCast(config.AppSettings, AppSettingsSection)
    Console.WriteLine("Section name: {0}", appSettings.SectionInformation.SectionName)

    ' Get the AppSettings section elements.
    Console.WriteLine()
    Console.WriteLine("Using AppSettings property.")
    Console.WriteLine("Application settings:")
    ' Get the KeyValueConfigurationCollection 
    ' from the configuration.
    Dim settings As KeyValueConfigurationCollection = config.AppSettings.Settings

    ' Display each KeyValueConfigurationElement.
    For Each keyValueElement As KeyValueConfigurationElement In settings
        Console.WriteLine("Key: {0}", keyValueElement.Key)
        Console.WriteLine("Value: {0}", keyValueElement.Value)
        Console.WriteLine()
    Next keyValueElement
Catch e As ConfigurationErrorsException
    Console.WriteLine("Using AppSettings property: {0}", e.ToString())
End Try

설명

사용 된 AppSettings 속성을 액세스 하 고 열려 있는 appSettings 구성 파일에서 기본적으로 정의 된 구성 섹션을 변경 합니다.

적용 대상