SortedDictionary<TKey,TValue>.Remove(TKey) Yöntem

Tanım

öğesinden SortedDictionary<TKey,TValue>belirtilen anahtara sahip öğesini kaldırır.

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

Parametreler

key
TKey

Kaldırılacak öğenin anahtarı.

Döndürülenler

true öğesi başarıyla kaldırılırsa; aksi takdirde , false. Bu yöntem, içinde falsebulunamazsa key da döndürürSortedDictionary<TKey,TValue>.

Uygulamalar

Özel durumlar

key, null'e eşittir.

Örnekler

Aşağıdaki kod örneği, yöntemini kullanarak sözlükten anahtar/değer çiftinin nasıl kaldırılacağını Remove gösterir.

Bu kod örneği, sınıfı için SortedDictionary<TKey,TValue> sağlanan daha büyük bir örneğin parçasıdır.

// 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

Açıklamalar

SortedDictionary<TKey,TValue> belirtilen anahtara sahip bir öğe içermiyorsa, SortedDictionary<TKey,TValue> değişmeden kalır. İstisna atılmaz.

Bu yöntem bir O(log n) işlemidir.

Şunlara uygulanır

Ayrıca bkz.