Configuration.AppSettings Configuration.AppSettings Configuration.AppSettings Configuration.AppSettings Property

定義

取得、AppSettingsSectionこれが適用されるオブジェクトの構成セクションConfigurationオブジェクト。Gets the AppSettingsSection object configuration section that applies to this Configuration object.

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オブジェクト。An AppSettingsSection object representing the appSettings configuration section that applies to this Configuration object.

次のコード例は、使用する方法を示します、AppSettingsプロパティ。The following code example demonstrates how to use the AppSettings property.

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既定では、開いている構成ファイルで定義されている構成セクション。Use the AppSettings property to access and change the appSettings configuration section defined by default in the open configuration file.

適用対象