SortedList<TKey,TValue>.Values Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
içindeki SortedList<TKey,TValue>değerleri içeren bir koleksiyon alır.
public:
property System::Collections::Generic::IList<TValue> ^ Values { System::Collections::Generic::IList<TValue> ^ get(); };
public System.Collections.Generic.IList<TValue> Values { get; }
member this.Values : System.Collections.Generic.IList<'Value>
Public ReadOnly Property Values As IList(Of TValue)
Özellik Değeri
IList<T> içindeki SortedList<TKey,TValue>değerleri içeren.
Örnekler
Bu kod örneği, özelliğini kullanarak Values sıralanmış listedeki değerlerin nasıl numaralandırılıp sıralanmış listedeki anahtarların ve değerlerin numaralandırılıp numaralandırılamını gösterir.
Örnekte ayrıca değerlerin Values verimli bir şekilde dizine alınması için özelliğinin nasıl kullanılacağı gösterilmektedir.
Bu kod örneği, sınıfı için SortedList<TKey,TValue> sağlanan daha büyük bir örneğin parçasıdır.
// To get the values alone, use the Values property.
IList<string> ilistValues = openWith.Values;
// The elements of the list are strongly typed with the
// type that was specified for the SortedList values.
Console.WriteLine();
foreach( string s in ilistValues )
{
Console.WriteLine("Value = {0}", s);
}
// The Values property is an efficient way to retrieve
// values by index.
Console.WriteLine("\nIndexed retrieval using the Values " +
"property: Values[2] = {0}", openWith.Values[2]);
' To get the values alone, use the Values property.
Dim ilistValues As IList(Of String) = openWith.Values
' The elements of the list are strongly typed with the
' type that was specified for the SortedList values.
Console.WriteLine()
For Each s As String In ilistValues
Console.WriteLine("Value = {0}", s)
Next s
' The Values property is an efficient way to retrieve
' values by index.
Console.WriteLine(vbLf & "Indexed retrieval using the " & _
"Values property: Values(2) = {0}", openWith.Values(2))
// To get the values alone, use the Values property.
let ilistValues = openWith.Values;
// The elements of the list are strongly typed with the
// type that was specified for the SortedList values.
Console.WriteLine()
for s in ilistValues do
printfn $"Value = {s}"
// The Values property is an efficient way to retrieve
// values by index.
printf "\nIndexed retrieval using the Values "
printfn $"property: Values[2] = {openWith.Values[2]}"
// When you use foreach to enumerate list 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 list 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
// When you use foreach to enumerate list elements,
// the elements are retrieved as KeyValuePair objects.
Console.WriteLine()
for kvp in openWith do
printfn $"Key = {kvp.Key}, Value = {kvp.Value}"
Açıklamalar
içindeki IList<T> değerlerin sırası, içindeki sırayla SortedList<TKey,TValue>aynıdır.
Döndürülen IList<T> , statik bir kopya değildir; bunun yerine, IList<T> özgün SortedList<TKey,TValue>içindeki değerlere geri başvurur. Bu nedenle, dosyasındaki SortedList<TKey,TValue> değişiklikler öğesine IList<T>yansıtılmaya devam edilir.
özelliği tarafından Values döndürülen koleksiyon, değerleri dizine göre almak için verimli bir yol sağlar. Özelliğe erişildiğinde listeyi yeniden oluşturmak gerekmez, çünkü liste yalnızca iç değer dizisi için bir sarmalayıcıdır. Aşağıdaki kod, sıralanmış bir dize listesinden değerlerin dizine alınan alınması için özelliğinin kullanımını Values gösterir:
string v = mySortedList.Values[3];
Dim v As String = mySortedList.Values(3)
let v = mySortedList.Values[3]
Bu özelliğin değerini almak bir O(1) işlemidir.