OrderedDictionary.RemoveAt(Int32) Yöntem

Tanım

Belirtilen dizindeki girdiyi koleksiyondan OrderedDictionary kaldırır.

public:
 virtual void RemoveAt(int index);
public void RemoveAt (int index);
abstract member RemoveAt : int -> unit
override this.RemoveAt : int -> unit
Public Sub RemoveAt (index As Integer)

Parametreler

index
Int32

Kaldırılacak girişin sıfır tabanlı dizini.

Uygulamalar

Özel durumlar

Koleksiyon OrderedDictionary salt okunurdur.

index, sıfırdan küçüktür.

-veya-

index eşittir veya değerinden Countbüyüktür.

Örnekler

Aşağıdaki kod örneği bir OrderedDictionary koleksiyonun değiştirilmesini gösterir. Bu örnekte yöntemi, RemoveAt özelliğiyle birlikte Count son girdiyi dosyasından 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 girişler, boşaltılan noktayı kaplayan yukarı taşınır ve taşınan girişlerin dizinleri de güncelleştirilir.

Şunlara uygulanır