IDictionary<TKey,TValue>.Keys Eigenschap

Definitie

Hiermee haalt u een ICollection<T> met de sleutels van de 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)

Waarde van eigenschap

ICollection<TKey>

Een ICollection<T> met de sleutels van het object dat wordt geïmplementeerd IDictionary<TKey,TValue>.

Voorbeelden

In het volgende codevoorbeeld ziet u hoe u alleen sleutels opsommen met behulp van de Keys eigenschap.

Deze code maakt deel uit van een groter voorbeeld dat kan worden gecompileerd en uitgevoerd. Zie 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

Opmerkingen

De volgorde van de sleutels in de geretourneerde ICollection<T> is niet opgegeven, maar het is gegarandeerd dezelfde volgorde als de bijbehorende waarden in de ICollection<T> geretourneerde Values eigenschap.

Van toepassing op

Zie ook