PropertyCollection.System.Collections.IDictionary.Add メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > PropertyCollection.System.Collections.IDictionary.Add メソッドの意味・解説 

PropertyCollection.System.Collections.IDictionary.Add メソッド

指定したキーおよび値を持つ要素を IDictionary オブジェクト追加します

名前空間: System.DirectoryServices
アセンブリ: 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)
void IDictionary.Add (
    Object key,
    Object value
)
private:
virtual void System.Collections.IDictionary.Add (
    Object^ key, 
    Object^ value
) sealed = IDictionary::Add

パラメータ

key

追加する要素キーとして使用する Object

value

追加する要素の値として使用する Object

例外例外
例外種類条件

ArgumentNullException

keynull 参照 (Visual Basic では Nothing) です。

ArgumentException

同じキー持つ要素が、IDictionary オブジェクトに既に存在します

NotSupportedException

IDictionary読み取り専用です。

または

IDictionary固定サイズです。

解説解説

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);
    }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

PropertyCollection.System.Collections.IDictionary.Add メソッドのお隣キーワード
検索ランキング

   

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



PropertyCollection.System.Collections.IDictionary.Add メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS