NameValueConfigurationCollection クラス
アセンブリ: System.Configuration (system.configuration.dll 内)

Public NotInheritable Class NameValueConfigurationCollection Inherits ConfigurationElementCollection

NameValueConfigurationCollection クラスを使用すると、NameValueConfigurationElement オブジェクトのコレクションにプログラムからアクセスできます。

NameValueConfigurationCollection 型を使用する方法を次のコード例に示します。
Imports System Imports System.Configuration Imports System.Web.Configuration Imports System.Collections Imports System.Text Namespace Samples.AspNet Class UsingNameValueConfigurationCollection Public Shared Sub Main() Try ' Set the path of the config file. Dim configPath As String = "" ' Get the Web application configuration object. Dim config As System.Configuration.Configuration = _ WebConfigurationManager.OpenWebConfiguration(configPath) ' Get the section related object. Dim configSection As _ AnonymousIdentificationSection = _ CType(config.GetSection("system.web/anonymousIdentification"), _ AnonymousIdentificationSection) ' Display title and info. Console.WriteLine("Configuration Info") Console.WriteLine() ' Display Config details. Console.WriteLine("File Path: {0}", _ config.FilePath) Console.WriteLine("Section Path: {0}", _ configSection.SectionInformation.Name) Console.WriteLine() ' Create a NameValueConfigurationCollection object. Dim myNameValConfigCollection As NameValueConfigurationCollection = _ New NameValueConfigurationCollection() For Each propertyItem As PropertyInformation In _ configSection.ElementInformation.Properties Dim nameValConfigElement As NameValueConfigurationElement = _ New NameValueConfigurationElement _ (propertyItem.Name.ToString(), propertyItem.Value.ToString()) ' Add a NameValueConfigurationElement ' to the collection. myNameValConfigCollection.Add(nameValConfigElement) Next ' Count property. Console.WriteLine("Collection Count: {0}", _ myNameValConfigCollection.Count) ' Item property. Console.WriteLine("Value of property 'enabled': {0}", _ myNameValConfigCollection.Item("enabled").Value) ' Display the contents of the collection. For Each configItem As NameValueConfigurationElement In _ myNameValConfigCollection Console.WriteLine() Console.WriteLine("Configuration Details:") Console.WriteLine("Name: {0}", configItem.Name) Console.WriteLine("Value: {0}", configItem.Value) Next ' Remove method. Dim myConfigElement As NameValueConfigurationElement = _ myNameValConfigCollection.Item("domain") myNameValConfigCollection.Remove(myConfigElement) ' Clear method. myNameValConfigCollection.Clear() Catch e As Exception ' Unknown error. Console.WriteLine(e.ToString()) End Try ' Display and wait. Console.ReadLine() End Sub End Class End Namespace
#region Using directives using System; using System.Configuration; using System.Web.Configuration; using System.Collections; using System.Text; #endregion namespace Samples.AspNet { class UsingNameValueConfigurationCollection { static void Main(string[] args) { try { // Set the path of the config file. string configPath = ""; // Get the Web application configuration object. Configuration config = WebConfigurationManager.OpenWebConfiguration(configPath); // Get the section related object. AnonymousIdentificationSection configSection = (AnonymousIdentificationSection)config.GetSection ("system.web/anonymousIdentification"); // Display title and info. Console.WriteLine("Configuration Info"); Console.WriteLine(); // Display Config details. Console.WriteLine("File Path: {0}", config.FilePath); Console.WriteLine("Section Path: {0}", configSection.SectionInformation.Name); Console.WriteLine(); // Create a NameValueConfigurationCollection object. NameValueConfigurationCollection myNameValConfigCollection = new NameValueConfigurationCollection(); foreach (PropertyInformation propertyItem in configSection.ElementInformation.Properties) { NameValueConfigurationElement nameValConfigElement = new NameValueConfigurationElement (propertyItem.Name.ToString(), propertyItem.Value.ToString()); // Add a NameValueConfigurationElement // to the collection. myNameValConfigCollection.Add(nameValConfigElement); } // Count property. Console.WriteLine("Collection Count: {0}", myNameValConfigCollection.Count); // Item property. Console.WriteLine("Value of property 'enabled': {0}", myNameValConfigCollection["enabled"].Value); // Display the contents of the collection. foreach (NameValueConfigurationElement configItem in myNameValConfigCollection) { Console.WriteLine(); Console.WriteLine("Configuration Details:"); Console.WriteLine("Name: {0}", configItem.Name); Console.WriteLine("Value: {0}", configItem.Value); } // Remove method. NameValueConfigurationElement myConfigElement = myNameValConfigCollection["domain"]; myNameValConfigCollection.Remove(myConfigElement); // Clear method. myNameValConfigCollection.Clear(); } catch (Exception e) { // Unknown error. Console.WriteLine(e.ToString()); } // Display and wait. Console.ReadLine(); } } }

System.Configuration.ConfigurationElement
System.Configuration.ConfigurationElementCollection
System.Configuration.NameValueConfigurationCollection


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


NameValueConfigurationCollection コンストラクタ
アセンブリ: System.Configuration (system.configuration.dll 内)


NameValueConfigurationCollection コンストラクタを使用する方法を次のコード例に示します。このコード例は、NameValueConfigurationCollection クラスのトピックで取り上げているコード例の一部分です。

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


NameValueConfigurationCollection クラス
NameValueConfigurationCollection メンバ
System.Configuration 名前空間
NameValueConfigurationCollection プロパティ

名前 | 説明 | |
---|---|---|
![]() | AllKeys | NameValueConfigurationCollection に格納されているすべての項目のキーを取得します。 |
![]() | CollectionType | ConfigurationElementCollection の型を取得します。 ( ConfigurationElementCollection から継承されます。) |
![]() | Count | コレクション内の要素の数を取得します。 ( ConfigurationElementCollection から継承されます。) |
![]() | ElementInformation | ConfigurationElement オブジェクトのカスタマイズできない情報と機能を格納する ElementInformation オブジェクトを取得します。 ( ConfigurationElement から継承されます。) |
![]() | EmitClear | コレクションが削除されているかどうかを指定します。 ( ConfigurationElementCollection から継承されます。) |
![]() | IsSynchronized | コレクションへのアクセスが同期されている (スレッド セーフである) かどうかを示す値を取得します。 ( ConfigurationElementCollection から継承されます。) |
![]() | Item | 指定されたパラメータに基づいて、NameValueConfigurationElement オブジェクトを取得または設定します。 |
![]() | LockAllAttributesExcept | ロックされている属性のコレクションを取得します。 ( ConfigurationElement から継承されます。) |
![]() | LockAllElementsExcept | ロックされている要素のコレクションを取得します。 ( ConfigurationElement から継承されます。) |
![]() | LockAttributes | ロックされている属性のコレクションを取得します。 ( ConfigurationElement から継承されます。) |
![]() | LockElements | ロックされている要素のコレクションを取得します。 ( ConfigurationElement から継承されます。) |
![]() | LockItem | 要素がロックされているかどうかを示す値を取得または設定します。 ( ConfigurationElement から継承されます。) |
![]() | SyncRoot | ConfigurationElementCollection へのアクセスを同期するために使用するオブジェクトを取得します。 ( ConfigurationElementCollection から継承されます。) |

NameValueConfigurationCollection メソッド

名前 | 説明 | |
---|---|---|
![]() | Add | NameValueConfigurationElement オブジェクトをコレクションに追加します。 |
![]() | Clear | NameValueConfigurationCollection を消去します。 |
![]() | CopyTo | ConfigurationElementCollection の内容を配列にコピーします。 ( ConfigurationElementCollection から継承されます。) |
![]() | Equals | オーバーロードされます。 ConfigurationElementCollection と指定したオブジェクトを比較します。 ( ConfigurationElementCollection から継承されます。) |
![]() | GetEnumerator | ConfigurationElementCollection の反復処理に使用する IEnumerator を取得します。 ( ConfigurationElementCollection から継承されます。) |
![]() | GetHashCode | ConfigurationElementCollection インスタンスを表す一意の値を取得します。 ( ConfigurationElementCollection から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | IsReadOnly | ConfigurationElementCollection オブジェクトが読み取り専用かどうかを示す値を取得します。 ( ConfigurationElementCollection から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | Remove | オーバーロードされます。 NameValueConfigurationElement オブジェクトをコレクションから削除します。 |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

NameValueConfigurationCollection メンバ
NameValueConfigurationElement オブジェクトのコレクションを格納します。このクラスは継承できません。
NameValueConfigurationCollection データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | AllKeys | NameValueConfigurationCollection に格納されているすべての項目のキーを取得します。 |
![]() | CollectionType | ConfigurationElementCollection の型を取得します。(ConfigurationElementCollection から継承されます。) |
![]() | Count | コレクション内の要素の数を取得します。(ConfigurationElementCollection から継承されます。) |
![]() | ElementInformation | ConfigurationElement オブジェクトのカスタマイズできない情報と機能を格納する ElementInformation オブジェクトを取得します。 (ConfigurationElement から継承されます。) |
![]() | EmitClear | コレクションが削除されているかどうかを指定します。(ConfigurationElementCollection から継承されます。) |
![]() | IsSynchronized | コレクションへのアクセスが同期されている (スレッド セーフである) かどうかを示す値を取得します。(ConfigurationElementCollection から継承されます。) |
![]() | Item | 指定されたパラメータに基づいて、NameValueConfigurationElement オブジェクトを取得または設定します。 |
![]() | LockAllAttributesExcept | ロックされている属性のコレクションを取得します。(ConfigurationElement から継承されます。) |
![]() | LockAllElementsExcept | ロックされている要素のコレクションを取得します。(ConfigurationElement から継承されます。) |
![]() | LockAttributes | ロックされている属性のコレクションを取得します。 (ConfigurationElement から継承されます。) |
![]() | LockElements | ロックされている要素のコレクションを取得します。(ConfigurationElement から継承されます。) |
![]() | LockItem | 要素がロックされているかどうかを示す値を取得または設定します。(ConfigurationElement から継承されます。) |
![]() | SyncRoot | ConfigurationElementCollection へのアクセスを同期するために使用するオブジェクトを取得します。(ConfigurationElementCollection から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Add | NameValueConfigurationElement オブジェクトをコレクションに追加します。 |
![]() | Clear | NameValueConfigurationCollection を消去します。 |
![]() | CopyTo | ConfigurationElementCollection の内容を配列にコピーします。 (ConfigurationElementCollection から継承されます。) |
![]() | Equals | オーバーロードされます。 ConfigurationElementCollection と指定したオブジェクトを比較します。 (ConfigurationElementCollection から継承されます。) |
![]() | GetEnumerator | ConfigurationElementCollection の反復処理に使用する IEnumerator を取得します。 (ConfigurationElementCollection から継承されます。) |
![]() | GetHashCode | ConfigurationElementCollection インスタンスを表す一意の値を取得します。 (ConfigurationElementCollection から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | IsReadOnly | ConfigurationElementCollection オブジェクトが読み取り専用かどうかを示す値を取得します。 (ConfigurationElementCollection から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | Remove | オーバーロードされます。 NameValueConfigurationElement オブジェクトをコレクションから削除します。 |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

Weblioに収録されているすべての辞書からNameValueConfigurationCollectionを検索する場合は、下記のリンクをクリックしてください。

- NameValueConfigurationCollectionのページへのリンク