SortedList<TKey,TValue>.Values 속성

정의

SortedList<TKey,TValue>의 값을 포함하는 컬렉션을 가져옵니다.

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)

속성 값

IList<TValue>

IList<T>의 값을 포함하는 SortedList<TKey,TValue>입니다.

예제

이 코드 예제에서는 속성을 사용하여 Values 정렬된 목록의 값을 열거하는 방법 및 정렬된 목록의 키와 값을 열거하는 방법을 보여줍니다.

이 예제에서는 값을 효율적으로 인덱싱한 검색을 위해 속성을 사용하는 Values 방법도 보여 집니다.

이 코드 예제는에 대해 제공 된 큰 예제의 일부는 SortedList<TKey,TValue> 클래스입니다.

// 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();
for each( 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.
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();
for each( 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();
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}"

설명

의 값 IList<T> 순서는 의 순서 SortedList<TKey,TValue>와 동일합니다.

반환 IList<T> 된 는 정적 복사본이 아니며, 대신 는 IList<T> 원래 SortedList<TKey,TValue>의 값을 다시 참조합니다. 따라서 에 대한 SortedList<TKey,TValue> 변경 내용은 에 계속 반영됩니다 IList<T>.

속성에서 반환된 Values 컬렉션은 인덱스별로 값을 검색하는 효율적인 방법을 제공합니다. 속성에 액세스할 때 목록을 다시 생성할 필요는 없습니다. 목록이 값의 내부 배열에 대한 래퍼이기 때문입니다. 다음 코드에서는 정렬된 문자열 목록에서 값의 인덱싱된 검색에 속성을 사용하는 Values 방법을 보여 줍니다.

String^ v = mySortedList->Values[3];
string v = mySortedList.Values[3];
Dim v As String = mySortedList.Values(3)
let v = mySortedList.Values[3]

이 속성 값을 검색하는 것은 O(1) 연산입니다.

적용 대상

추가 정보