IDictionary<TKey,TValue>.Keys Egenskap
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar en ICollection<T> som innehåller nycklarna för 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)
Egenskapsvärde
En ICollection<T> som innehåller nycklarna för objektet som implementerar IDictionary<TKey,TValue>.
Exempel
I följande kodexempel visas hur du räknar upp enbart nycklar med hjälp av Keys egenskapen .
Den här koden är en del av ett större exempel som kan kompileras och köras. Se även 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
Kommentarer
Ordningen på nycklarna i den returnerade ICollection<T> är ospecificerad, men den är garanterad att vara samma ordning som motsvarande värden i den ICollection<T> som returneras av Values egenskapen.