SortedDictionary<TKey,TValue>.Remove(TKey) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定したキーを持つ要素を SortedDictionary<TKey,TValue>から削除します。
public:
virtual bool Remove(TKey key);
public bool Remove(TKey key);
abstract member Remove : 'Key -> bool
override this.Remove : 'Key -> bool
Public Function Remove (key As TKey) As Boolean
パラメーター
- key
- TKey
削除する要素のキー。
返品
true 要素が正常に削除された場合。それ以外の場合は false。 このメソッドは、falseでkeyが見つからない場合にもSortedDictionary<TKey,TValue>を返します。
実装
例外
key は nullです。
例
次のコード例は、 Remove メソッドを使用してディクショナリからキーと値のペアを削除する方法を示しています。
このコード例は、 SortedDictionary<TKey,TValue> クラスに提供されるより大きな例の一部です。
// 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.");
}
' 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
注釈
指定したキーを持つ要素が SortedDictionary<TKey,TValue> に含まれていない場合、 SortedDictionary<TKey,TValue> は変更されません。 例外はスローされません。
このメソッドは O(ログ n) 操作です。