Bagikan melalui


IDictionary<TKey,TValue>.Keys Properti

Definisi

Mendapatkan yang ICollection<T> berisi kunci 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)

Nilai Properti

ICollection<TKey>

Yang ICollection<T> berisi kunci objek yang mengimplementasikan IDictionary<TKey,TValue>.

Contoh

Contoh kode berikut menunjukkan cara menghitung kunci saja menggunakan Keys properti .

Kode ini adalah bagian dari contoh yang lebih besar yang dapat dikompilasi dan dijalankan. Lihat 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

Keterangan

Urutan kunci dalam yang dikembalikan ICollection<T> tidak ditentukan, tetapi dijamin urutannya sama dengan nilai yang sesuai dalam ICollection<T> yang dikembalikan oleh Values properti .

Berlaku untuk

Lihat juga