IDictionary.Remove メソッドとは? わかりやすく解説

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

IDictionary.Remove メソッド

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

指定したキー持つ要素を IDictionary から削除します

名前空間: System.Collections.Generic
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

例外例外
例外種類条件

ArgumentNullException

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

NotSupportedException

IDictionary読み取り専用です。

解説解説
使用例使用例

Remove メソッド使用してキー/値ペアをディクショナリから削除する方法次のコード例示します

このコードは、コンパイルして実行することのできる例の一部です。詳細については、System.Collections.Generic.IDictionaryトピック参照してください

' Use the Remove method to remove a key/value pair.
Console.WriteLine(vbLf + "Remove(""doc"")")
openWith.Remove("doc")

If Not openWith.ContainsKey("doc")
 Then
    Console.WriteLine("Key ""doc""
 is not found.")
End If
// Use the Remove method to remove a key/value pair.
Console.WriteLine("\nRemove(\"doc\")");
openWith.Remove("doc");

if (!openWith.ContainsKey("doc"))
{
    Console.WriteLine("Key \"doc\" is not found.");
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IDictionary ジェネリック インターフェイス
IDictionary メンバ
System.Collections.Generic 名前空間
ICollection.IsReadOnly プロパティ

IDictionary.Remove メソッド

指定したキー持つ要素を IDictionary オブジェクトから削除します

名前空間: System.Collections
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

例外例外
例外種類条件

ArgumentNullException

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

NotSupportedException

IDictionary読み取り専用です。

または

IDictionary固定サイズです。

解説解説

指定したキー持つ要素IDictionary オブジェクト格納されていない場合IDictionary変更されません。例外スローされません。

使用例使用例

Remove メソッド実装する方法次のコード例示します。このコード例は、IDictionary クラストピック取り上げているコード例一部です。

Public Sub Remove(ByVal
 key As Object) Implements
 IDictionary.Remove
    If key = Nothing Then
        Throw New ArgumentNullException("key")
    End If
    ' Try to find the key in the DictionaryEntry array
    Dim index As Integer
    If TryGetIndexOfKey(key, index) Then

        ' If the key is found, slide all the items up.
        Array.Copy(items, index + 1, items, index, (ItemsInUse - index) - 1)
        ItemsInUse = ItemsInUse - 1
    Else

        ' If the key is not in the dictionary, just return. 
    End If
End Sub
public void Remove(object key)
{
    if (key == null) throw new
 ArgumentNullException("key");
    // Try to find the key in the DictionaryEntry array
    Int32 index;
    if (TryGetIndexOfKey(key, out index))
    {
        // If the key is found, slide all the items up.
        Array.Copy(items, index + 1, items, index, ItemsInUse - index - 1);
        ItemsInUse--;
    } 
    else
    {
        // If the key is not in the dictionary, just return. 
    }
}
public:
    virtual void Remove(Object^ key)
    {
        if (key == nullptr)
        {
            throw gcnew ArgumentNullException("key");
        }
        // Try to find the key in the DictionaryEntry array
        int index;
        if (TryGetIndexOfKey(key, &index))
        {
            // If the key is found, slide all the items down.
            Array::Copy(items, index + 1, items, index, itemsInUse -
                index - 1);
            itemsInUse--;
        }
        else
        {
            // If the key is not in the dictionary, just return.
            return;
        }
    }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

「IDictionary.Remove メソッド」の関連用語

IDictionary.Remove メソッドのお隣キーワード
検索ランキング

   

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



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

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

©2024 GRAS Group, Inc.RSS