Condividi tramite


IDictionary<TKey,TValue>.Keys Proprietà

Definizione

Ottiene un oggetto ICollection<T> contenente le chiavi dell'oggetto IDictionary<TKey,TValue>.

public:
 property System::Collections::Generic::ICollection<TKey> ^ Keys { System::Collections::Generic::ICollection<TKey> ^ get(); };
public System.Collections.Generic.ICollection<TKey> Keys { get; }
member this.Keys : System.Collections.Generic.ICollection<'Key>
Public ReadOnly Property Keys As ICollection(Of TKey)

Valore della proprietà

ICollection<TKey>

Oggetto ICollection<T> contenente le chiavi dell'oggetto che implementa IDictionary<TKey,TValue>.

Esempio

Nell'esempio di codice seguente viene illustrato come enumerare solo le chiavi usando la Keys proprietà .

Questo codice fa parte di un esempio più ampio che può essere compilato ed eseguito. Vedi System.Collections.Generic.IDictionary<TKey,TValue>.

// To get the keys alone, use the Keys property.
icoll = openWith.Keys;

// The elements of the ValueCollection are strongly typed
// with the type that was specified for dictionary values.
Console.WriteLine();
foreach( string s in icoll )
{
    Console.WriteLine("Key = {0}", s);
}
' To get the keys alone, use the Keys property.
icoll = openWith.Keys

' The elements of the ValueCollection are strongly typed
' with the type that was specified for dictionary values.
Console.WriteLine()
For Each s As String In  icoll
    Console.WriteLine("Key = {0}", s)
Next s

Commenti

L'ordine delle chiavi nell'oggetto restituito ICollection<T> non è specificato, ma è garantito che sia lo stesso ordine dei valori corrispondenti nell'oggetto ICollection<T> restituito dalla Values proprietà .

Si applica a

Vedi anche