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



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「AppSettingsSection」の関連用語

AppSettingsSectionのお隣キーワード
検索ランキング

   

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



AppSettingsSectionのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS