KeyValueConfigurationElement クラスとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > KeyValueConfigurationElement クラスの意味・解説 

KeyValueConfigurationElement クラス

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

キーと値のペア格納する構成要素表します

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

Public Class KeyValueConfigurationElement
    Inherits ConfigurationElement
Dim instance As KeyValueConfigurationElement
public class KeyValueConfigurationElement :
 ConfigurationElement
public ref class KeyValueConfigurationElement
 : public ConfigurationElement
public class KeyValueConfigurationElement extends
 ConfigurationElement
public class KeyValueConfigurationElement extends
 ConfigurationElement
解説解説

KeyValueConfigurationElement オブジェクトは ConfigurationElement 基本クラスから継承しますConfigurationElement オブジェクトは、構成ファイル内の要素表しますKeyValueConfigurationElement オブジェクトは、KeyValueConfigurationCollection コレクション属することができます

使用例使用例

KeyValueConfigurationElement クラスメンバ使用する方法次のコード例示します

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.Configuration;

namespace Samples.Aspnet.Config
{
  class KeyValueConfigCollection
  {
    static void Main(string[]
 args)
    {
      try
      {
        // Set the path of the config file.
        string configPath = "/aspnet";

        // Get the Web application configuration object.
        Configuration config =
          WebConfigurationManager.OpenWebConfiguration(configPath);

        // Get the section related object.
        AppSettingsSection configSection =
          (AppSettingsSection)config.GetSection
          ("appSettings");

        // Display title and info.
        Console.WriteLine("ASP.NET Configuration Info");
        Console.WriteLine();

        // Display Config details.
        Console.WriteLine("File Path: {0}",
          config.FilePath);
        Console.WriteLine("Section Path: {0}",
          configSection.SectionInformation.Name.ToString());
        Console.WriteLine();

        // Create the KeyValueConfigurationElement.
        KeyValueConfigurationElement myAdminKeyVal = 
          new KeyValueConfigurationElement(
          "myAdminTool", "admin.aspx");

        // Determine if the configuration contains
        // any KeyValueConfigurationElements.
        KeyValueConfigurationCollection configSettings = 
          config.AppSettings.Settings;
        if (configSettings.AllKeys.Length == 0)
        {
          // Add KeyValueConfigurationElement to collection.
          config.AppSettings.Settings.Add(myAdminKeyVal);

          if (!configSection.SectionInformation.IsLocked)
          {
            config.Save();
            Console.WriteLine("** Configuration updated.");
          }
          else
          {
            Console.WriteLine("** Could not update, section is locked.");
          }
        }

        // 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 (Exception e)
      {
        // Unknown error.
        Console.WriteLine(e.ToString());
      }

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


このページでは「.NET Framework クラス ライブラリ リファレンス」からKeyValueConfigurationElement クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からKeyValueConfigurationElement クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からKeyValueConfigurationElement クラス を検索

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

辞書ショートカット

すべての辞書の索引

「KeyValueConfigurationElement クラス」の関連用語

KeyValueConfigurationElement クラスのお隣キーワード
検索ランキング

   

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



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

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

©2025 GRAS Group, Inc.RSS