IDictionary<TKey,TValue>.Keys Właściwość

Definicja

Pobiera element ICollection<T> zawierający klucze elementu 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)

Wartość właściwości

ICollection<TKey>

Obiekt ICollection<T> zawierający klucze obiektu, który implementuje IDictionary<TKey,TValue>element .

Przykłady

W poniższym przykładzie kodu pokazano, jak wyliczać klucze samodzielnie przy użyciu Keys właściwości .

Ten kod jest częścią większego przykładu, który można skompilować i wykonać. Zobacz: 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();
for each( 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();
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

Uwagi

Kolejność kluczy zwróconych ICollection<T> jest nieokreślona, ale gwarantowana jest taka sama kolejność jak odpowiadające im wartości zwrócone ICollection<T> przez Values właściwość.

Dotyczy

Zobacz też