DictionaryEntry.Key Propriété

Définition

Obtient ou définit la clé dans la paire clé/valeur.

public:
 property System::Object ^ Key { System::Object ^ get(); void set(System::Object ^ value); };
public object Key { get; set; }
member this.Key : obj with get, set
Public Property Key As Object

Valeur de propriété

La clé dans la paire clé/valeur.

Exemples

L’exemple suivant illustre la Key propriété . Cet exemple de code fait partie d’un exemple plus grand fourni pour la DictionaryEntry classe .

public:
    virtual void Add(Object^ key, Object^ value)
    {
        // Add the new key/value pair even if this key already exists
        // in the dictionary.
        if (itemsInUse == items->Length)
        {
            throw gcnew InvalidOperationException
                ("The dictionary cannot hold any more items.");
        }
        items[itemsInUse++] = gcnew DictionaryEntry(key, value);
    }
public void Add(object key, object value)
{
    // Add the new key/value pair even if this key already exists in the dictionary.
    if (ItemsInUse == items.Length)
        throw new InvalidOperationException("The dictionary cannot hold any more items.");
    items[ItemsInUse++] = new DictionaryEntry(key, value);
}
Public Sub Add(ByVal key As Object, ByVal value As Object) Implements IDictionary.Add

    ' Add the new key/value pair even if this key already exists in the dictionary.
    If ItemsInUse = items.Length Then
        Throw New InvalidOperationException("The dictionary cannot hold any more items.")
    End If
    items(ItemsInUse) = New DictionaryEntry(key, value)
    ItemsInUse = ItemsInUse + 1
End Sub

S’applique à