OrderedDictionary.Count OrderedDictionary.Count OrderedDictionary.Count OrderedDictionary.Count Property

Definition

Ruft die Anzahl der Schlüssel-Wert-Paare in der OrderedDictionary-Auflistung ab.Gets the number of key/values pairs contained in the OrderedDictionary collection.

public:
 property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer

Eigenschaftswert

Die Anzahl der Schlüssel-Wert-Paare in der OrderedDictionary-Auflistung.The number of key/value pairs contained in the OrderedDictionary collection.

Implementiert

Beispiele

Im folgenden Codebeispiel wird die Änderung einer OrderedDictionary -Auflistung veranschaulicht.The following code example demonstrates the modification of an OrderedDictionary collection. In diesem Beispiel wird die Count -Eigenschaft verwendet, um das letzte Element in der OrderedDictionaryzu entfernen.In this example, the Count property is used to remove the last item in the OrderedDictionary. Dieser Code ist Teil eines größeren Code Beispiels, das unter OrderedDictionaryangezeigt werden kann.This code is part of a larger code example that can be viewed at OrderedDictionary.

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

Gilt für: