OrderedDictionary.Remove(Object) Yöntem

Tanım

Belirtilen anahtara sahip girişi koleksiyondan OrderedDictionary kaldırır.

public:
 virtual void Remove(System::Object ^ key);
public void Remove (object key);
abstract member Remove : obj -> unit
override this.Remove : obj -> unit
Public Sub Remove (key As Object)

Parametreler

key
Object

Kaldırılacak girişin anahtarı.

Uygulamalar

Özel durumlar

Koleksiyon OrderedDictionary salt okunurdur.

key, null değeridir.

Örnekler

Aşağıdaki kod örneği, bir OrderedDictionary koleksiyonun değiştirilmesini gösterir. Bu örnekte yöntemi anahtarıyla Remove girdisini dosyasından "keyToDelete"OrderedDictionarykaldırmak için kullanılır. Bu kod, adresinde OrderedDictionarygörüntülenebilen daha büyük bir kod örneğinin parçasıdır.

// Modifying the OrderedDictionary
if (!myOrderedDictionary->IsReadOnly)
{
    // Insert a new key to the beginning of the OrderedDictionary
    myOrderedDictionary->Insert(0, "insertedKey1", "insertedValue1");

    // Modify the value of the entry with the key "testKey2"
    myOrderedDictionary["testKey2"] = "modifiedValue";

    // Remove the last entry from the OrderedDictionary: "testKey3"
    myOrderedDictionary->RemoveAt(myOrderedDictionary->Count - 1);

    // Remove the "keyToDelete" entry, if it exists
    if (myOrderedDictionary->Contains("keyToDelete"))
    {
        myOrderedDictionary->Remove("keyToDelete");
    }
}
// Modifying the OrderedDictionary
if (!myOrderedDictionary.IsReadOnly)
{
    // Insert a new key to the beginning of the OrderedDictionary
    myOrderedDictionary.Insert(0, "insertedKey1", "insertedValue1");

    // Modify the value of the entry with the key "testKey2"
    myOrderedDictionary["testKey2"] = "modifiedValue";

    // Remove the last entry from the OrderedDictionary: "testKey3"
    myOrderedDictionary.RemoveAt(myOrderedDictionary.Count - 1);

    // Remove the "keyToDelete" entry, if it exists
    if (myOrderedDictionary.Contains("keyToDelete"))
    {
        myOrderedDictionary.Remove("keyToDelete");
    }
}
' Modifying the OrderedDictionary
If Not myOrderedDictionary.IsReadOnly Then

    ' Insert a new key to the beginning of the OrderedDictionary
    myOrderedDictionary.Insert(0, "insertedKey1", "insertedValue1")

    ' Modify the value of the entry with the key "testKey2"
    myOrderedDictionary("testKey2") = "modifiedValue"

    ' Remove the last entry from the OrderedDictionary: "testKey3"
    myOrderedDictionary.RemoveAt(myOrderedDictionary.Count - 1)

    ' Remove the "keyToDelete" entry, if it exists
    If (myOrderedDictionary.Contains("keyToDelete")) Then
        myOrderedDictionary.Remove("keyToDelete")
    End If
End If

Açıklamalar

Kaldırılan girdiyi izleyen girdiler, boşaltılan noktayı kaplayan yukarı taşınır ve taşınan girdilerin dizinleri de güncelleştirilir.

Koleksiyon belirtilen anahtara OrderedDictionary sahip bir giriş içermiyorsa, OrderedDictionary değeri değişmeden kalır ve hiçbir özel durum oluşturmaz.

Şunlara uygulanır