PropertyCollection.System.Collections.IDictionary.Add メソッド
アセンブリ: System.DirectoryServices (system.directoryservices.dll 内)

Private Sub System.Collections.IDictionary.Add ( _ key As Object, _ value As Object _ ) Implements IDictionary.Add
Dim instance As PropertyCollection Dim key As Object Dim value As Object CType(instance, IDictionary).Add(key, value)
private: virtual void System.Collections.IDictionary.Add ( Object^ key, Object^ value ) sealed = IDictionary::Add


Item プロパティを使用すると、ディクショナリ内に存在しないキーの値を設定することで、新しい要素を追加することもできます (例 : myCollection["myNonexistentKey"] = myValue)。ただし、指定したキーがディクショナリに既に存在する場合、Item プロパティを設定すると、既存の値が上書きされます。対照的に、Add メソッドは既存の要素を変更しません。

Add メソッドを実装する方法の例を次に示します。このコード例は、IDictionary クラスのトピックで取り上げているコード例の一部です。
Public Sub Add(ByVal key As Object, ByVal value As Object) Implements IDictionary.Add ' Add the new key/value pair even if this key already exists in the dictionary. If ItemsInUse = items.Length Then Throw New InvalidOperationException("The dictionary cannot hold any more items.") End If items(ItemsInUse) = New DictionaryEntry(key, value) ItemsInUse = ItemsInUse + 1 End Sub
public void Add(object key, object value) { // Add the new key/value pair even if this key already exists in the dictionary. if (ItemsInUse == items.Length) throw new InvalidOperationException("The dictionary cannot hold any more items."); items[ItemsInUse++] = new DictionaryEntry(key, value); }
public: virtual void Add(Object^ key, Object^ value) { // Add the new key/value pair even if this key already exists // in the dictionary. if (itemsInUse == items->Length) { throw gcnew InvalidOperationException ("The dictionary cannot hold any more items."); } items[itemsInUse++] = gcnew DictionaryEntry(key, value); }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からPropertyCollection.System.Collections.IDictionary.Add メソッドを検索する場合は、下記のリンクをクリックしてください。

- PropertyCollection.System.Collections.IDictionary.Add メソッドのページへのリンク