SortedDictionary<TKey,TValue>.Keys Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém uma coleção contendo as chaves em .SortedDictionary<TKey,TValue>
public:
property System::Collections::Generic::SortedDictionary<TKey, TValue>::KeyCollection ^ Keys { System::Collections::Generic::SortedDictionary<TKey, TValue>::KeyCollection ^ get(); };
public System.Collections.Generic.SortedDictionary<TKey,TValue>.KeyCollection Keys { get; }
member this.Keys : System.Collections.Generic.SortedDictionary<'Key, 'Value>.KeyCollection
Public ReadOnly Property Keys As SortedDictionary(Of TKey, TValue).KeyCollection
Valor de Propriedade
A contendo SortedDictionary<TKey,TValue>.KeyCollection as chaves no SortedDictionary<TKey,TValue>.
Exemplos
O seguinte exemplo de código mostra como enumerar as chaves no dicionário usando a Keys propriedade e como enumerar as chaves e valores no dicionário.
Este código faz parte de um exemplo maior que pode ser compilado e executado. Consulte SortedDictionary<TKey,TValue>.
// To get the keys alone, use the Keys property.
SortedDictionary<string, string>.KeyCollection keyColl =
openWith.Keys;
// The elements of the KeyCollection are strongly typed
// with the type that was specified for dictionary keys.
Console.WriteLine();
foreach( string s in keyColl )
{
Console.WriteLine("Key = {0}", s);
}
' To get the keys alone, use the Keys property.
Dim keyColl _
As SortedDictionary(Of String, String).KeyCollection = _
openWith.Keys
' The elements of the KeyCollection are strongly typed
' with the type that was specified for dictionary keys.
Console.WriteLine()
For Each s As String In keyColl
Console.WriteLine("Key = {0}", s)
Next s
// When you use foreach to enumerate dictionary elements,
// the elements are retrieved as KeyValuePair objects.
Console.WriteLine();
foreach( KeyValuePair<string, string> kvp in openWith )
{
Console.WriteLine("Key = {0}, Value = {1}",
kvp.Key, kvp.Value);
}
' When you use foreach to enumerate dictionary elements,
' the elements are retrieved as KeyValuePair objects.
Console.WriteLine()
For Each kvp As KeyValuePair(Of String, String) In openWith
Console.WriteLine("Key = {0}, Value = {1}", _
kvp.Key, kvp.Value)
Next kvp
Observações
As chaves em são SortedDictionary<TKey,TValue>.KeyCollection ordenadas de acordo com a Comparer propriedade e estão na mesma ordem que os valores associados em e SortedDictionary<TKey,TValue>.ValueCollection devolvidos pela Values propriedade.
O retornado SortedDictionary<TKey,TValue>.KeyCollection não é uma cópia estática; em vez disso, o SortedDictionary<TKey,TValue>.KeyCollection refere-se às chaves no original SortedDictionary<TKey,TValue>. Portanto, as alterações ao SortedDictionary<TKey,TValue> continuam a ser refletidas no SortedDictionary<TKey,TValue>.KeyCollection.
Obter o valor desta propriedade é uma operação O(1).