IDictionary.Remove メソッド
アセンブリ: mscorlib (mscorlib.dll 内)
![構文](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
Dim instance As IDictionary(Of TKey, TValue) Dim key As TKey Dim returnValue As Boolean returnValue = instance.Remove(key)
戻り値
要素が正常に削除された場合は true。それ以外の場合は false。このメソッドは、key が元の IDictionary に見つからなかった場合にも false を返します。
![例外](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
![解説](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
オブジェクトが等しいかどうかを判断する方法で実装が異なります。たとえば、List クラスでは Comparer.Default が使用されます。また、Dictionary クラスでは、IComparer 実装をキーの比較に使うかどうかをユーザーが指定できます。
![使用例](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
Remove メソッドを使用してキー/値ペアをディクショナリから削除する方法を次のコード例に示します。
このコードは、コンパイルして実行することのできる例の一部です。詳細については、System.Collections.Generic.IDictionary のトピックを参照してください。
![プラットフォーム](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
![バージョン情報](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
![参照](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
IDictionary ジェネリック インターフェイス
IDictionary メンバ
System.Collections.Generic 名前空間
ICollection.IsReadOnly プロパティ
IDictionary.Remove メソッド
アセンブリ: mscorlib (mscorlib.dll 内)
![構文](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
![例外](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
![解説](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
![使用例](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
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; } }
![プラットフォーム](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
![バージョン情報](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
![参照](http://weblio.hs.llnwd.net/e7/img/dict/msdnc/minus.gif)
- IDictionary.Remove メソッドのページへのリンク