AppSettingsSectionとは? わかりやすく解説

AppSettingsSection クラス

メモ : このクラスは、.NET Framework version 2.0 で新しく追加されたものです。

構成システムに appSettings 構成セクションのサポートを提供します。このクラスは継承できません。

名前空間: System.Configuration
アセンブリ: System.Configuration (system.configuration.dll 内)
構文構文

Public NotInheritable Class
 AppSettingsSection
    Inherits ConfigurationSection
Dim instance As AppSettingsSection
public sealed class AppSettingsSection : ConfigurationSection
public ref class AppSettingsSection sealed
 : public ConfigurationSection
public final class AppSettingsSection extends
 ConfigurationSection
public final class AppSettingsSection extends
 ConfigurationSection
解説解説
使用例使用例

AppSettingsSection オブジェクトを ConfigurationManager クラスのプロパティとして使用する方法を次のコード例に示します。

Imports System.Configuration
Imports System.Collections.Specialized


Module UsingAppSettingsSection
  Sub ShowAppSettings()
    Dim names As String()
 = ConfigurationManager.AppSettings.AllKeys
    Dim appStgs As NameValueCollection = ConfigurationManager.AppSettings
    Dim i As Integer
    For i = 0 To appStgs.Count - 1
      Console.WriteLine("#{0} Name: {1} Value: {2}",
 _
        i, names(i), appStgs(i))

    Next
  End Sub

  Sub Main()
    ' Uncomment the following line to set My.User to the currently logged
 on Windows user.
    ' My.User.InitializeWithWindowsUser

    Console.WriteLine("Application Settings Before:")
    ShowAppSettings()
    Console.WriteLine()
    Console.WriteLine("Add an Application Setting.")

    ' Get the count of the Application Settings.
    Dim appStgCnt As Integer
 = ConfigurationManager.AppSettings.Count
    Dim asName As String
 = "AppStg" + appStgCnt.ToString()

    ' Get the configuration file.
    Dim config As Configuration = _
           ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)

    ' Add an Application Setting.
    config.AppSettings.Settings.Add(asName, _
        DateTime.Now.ToLongDateString() + " " + _
        DateTime.Now.ToLongTimeString())

    ' Save the configuration file.
    config.Save(ConfigurationSaveMode.Modified)

    ' Force a reload of a changed section.
    ConfigurationManager.RefreshSection("appSettings")

    Console.WriteLine()
    Console.WriteLine("Application Settings After:")
    ShowAppSettings()
    Console.WriteLine()

    ' Show the value of a named Application Setting.
    Console.WriteLine( _
        "The value of application setting {0} is
 '{1}'.", _
        asName, ConfigurationManager.AppSettings(asName))

    Console.WriteLine()
    Console.WriteLine("Press 'Enter' to exit.")
    Console.ReadLine()
  End Sub
End Module
using System;
using System.Collections.Specialized;
using System.Configuration;

namespace ConfigurationSamples
{
  class UsingAppSettingsSection
  {
    static void ShowAppSettings()
    {
      string[] names = ConfigurationManager.AppSettings.AllKeys;
      NameValueCollection appStgs = ConfigurationManager.AppSettings;
      for (int i = 0; i < appStgs.Count;
 i++)
      {
        Console.WriteLine("#{0} Name: {1} Value: {2}",
          i, names[i], appStgs[i]);
      }
    }

    static void Main(string[]
 args)
    {
      Console.WriteLine("Application Settings Before:");
      ShowAppSettings();
      Console.WriteLine();
      Console.WriteLine("Add an Application Setting.");

      // Get the count of the Application Settings.
      int appStgCnt = ConfigurationManager.AppSettings.Count;
      string asName = "AppStg" + appStgCnt.ToString();

      // Get the configuration file.
      System.Configuration.Configuration config =
        ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

      // Add an Application Setting.
      config.AppSettings.Settings.Add(asName,
        DateTime.Now.ToLongDateString() + " " +
        DateTime.Now.ToLongTimeString());

      // Save the configuration file.
      config.Save(ConfigurationSaveMode.Modified);

      // Force a reload of a changed section.
      ConfigurationManager.RefreshSection("appSettings");

      Console.WriteLine();
      Console.WriteLine("Application Settings After:");
      ShowAppSettings();
      Console.WriteLine();

      // Show the value of a named Application Setting.
      Console.WriteLine(
        "The value of application setting {0} is '{1}'.",
        asName, ConfigurationManager.AppSettings[asName]);

      Console.WriteLine();
      Console.WriteLine("Press 'Enter' to exit.");
      Console.ReadLine();
    }
  }
}
継承階層継承階層
System.Object
   System.Configuration.ConfigurationElement
     System.Configuration.ConfigurationSection
      System.Configuration.AppSettingsSection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

AppSettingsSection コンストラクタ


AppSettingsSection プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ ElementInformation  ConfigurationElement オブジェクトのカスタマイズできない情報と機能を格納する ElementInformation オブジェクトを取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ File 追加設定の指定、または appSettings 要素で指定された設定のオーバーライドを行う構成ファイルを取得または設定します。
パブリック プロパティ LockAllAttributesExcept  ロックされている属性のコレクションを取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ LockAllElementsExcept  ロックされている要素のコレクションを取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ LockAttributes  ロックされている属性のコレクションを取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ LockElements  ロックされている要素のコレクションを取得します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ LockItem  要素がロックされているかどうかを示す値を取得または設定します。 ( ConfigurationElement から継承されます。)
パブリック プロパティ SectionInformation  ConfigurationSection オブジェクトのカスタマイズできない情報と機能を格納する SectionInformation オブジェクトを取得します。 ( ConfigurationSection から継承されます。)
パブリック プロパティ Settings 構成ファイルのアプリケーション設定を格納している NameValueCollection コレクションを取得します。
参照参照

関連項目

AppSettingsSection クラス
System.Configuration 名前空間
ConfigurationManager
WebConfigurationManager

AppSettingsSection メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

AppSettingsSection クラス
System.Configuration 名前空間
ConfigurationManager
WebConfigurationManager

AppSettingsSection メンバ

構成システムに appSettings 構成セクションのサポートを提供します。このクラスは継承できません。

AppSettingsSection データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド AppSettingsSection AppSettingsSection クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ ElementInformation  ConfigurationElement オブジェクトのカスタマイズできない情報と機能を格納する ElementInformation オブジェクトを取得します。 (ConfigurationElement から継承されます。)
パブリック プロパティ File 追加設定の指定、または appSettings 要素で指定された設定のオーバーライドを行う構成ファイルを取得または設定します。
パブリック プロパティ LockAllAttributesExcept  ロックされている属性のコレクションを取得します。(ConfigurationElement から継承されます。)
パブリック プロパティ LockAllElementsExcept  ロックされている要素のコレクションを取得します。(ConfigurationElement から継承されます。)
パブリック プロパティ LockAttributes  ロックされている属性のコレクションを取得します。 (ConfigurationElement から継承されます。)
パブリック プロパティ LockElements  ロックされている要素のコレクションを取得します。(ConfigurationElement から継承されます。)
パブリック プロパティ LockItem  要素がロックされているかどうかを示す値を取得または設定します。(ConfigurationElement から継承されます。)
パブリック プロパティ SectionInformation  ConfigurationSection オブジェクトのカスタマイズできない情報と機能を格納する SectionInformation オブジェクトを取得します。 (ConfigurationSection から継承されます。)
パブリック プロパティ Settings 構成ファイルのアプリケーション設定を格納している NameValueCollection コレクションを取得します。
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

AppSettingsSection クラス
System.Configuration 名前空間
ConfigurationManager
WebConfigurationManager



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「AppSettingsSection」の関連用語

AppSettingsSectionのお隣キーワード

   

英語⇒日本語
日本語⇒英語
   



AppSettingsSectionのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS