IDictionary<TKey,TValue>.Keys Свойство

Определение

Возвращает интерфейс ICollection<T>, содержащий ключи 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)

Значение свойства

ICollection<TKey>

Интерфейс ICollection<T>, содержащий ключи объекта, который реализует IDictionary<TKey,TValue>.

Примеры

В следующем примере кода показано, как перечислять ключи только с помощью Keys свойства.

Этот код является частью более крупного примера, который можно скомпилировать и выполнить. См. раздел 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

Комментарии

Порядок возвращаемых ICollection<T> ключей не указан, но гарантированно будет таким же, как и соответствующие значения в ICollection<T> возвращаемом свойстве Values .

Применяется к

См. также раздел