IDictionary<TKey,TValue>.Values Egenskap

Definition

Hämtar en ICollection<T> som innehåller värdena i IDictionary<TKey,TValue>.

public:
 property System::Collections::Generic::ICollection<TValue> ^ Values { System::Collections::Generic::ICollection<TValue> ^ get(); };
public System.Collections.Generic.ICollection<TValue> Values { get; }
member this.Values : System.Collections.Generic.ICollection<'Value>
Public ReadOnly Property Values As ICollection(Of TValue)

Egenskapsvärde

ICollection<TValue>

En ICollection<T> som innehåller värdena i objektet som implementerar IDictionary<TKey,TValue>.

Exempel

I följande kodexempel visas hur du räknar upp enbart värden med hjälp av Values 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 values alone, use the Values property.
ICollection<string> icoll = openWith.Values;

// 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("Value = {0}", s);
}
' To get the values alone, use the Values property.
Dim icoll As ICollection(Of String) = openWith.Values

' 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("Value = {0}", s)
Next s

Kommentarer

Ordningen på värdena i den returnerade ICollection<T> är ospecificerad, men den är garanterad att vara samma ordning som motsvarande nycklar i den ICollection<T> som returneras av Keys egenskapen.

Gäller för

Se även