SortedList<TKey,TValue>.Values 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
의 값을 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<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();
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}"
설명
값의 IList<T> 순서는 .의 순서 SortedList<TKey,TValue>와 같습니다.
반환 IList<T> 된 복사본은 정적 복사본 IList<T> 이 아니라 원래 SortedList<TKey,TValue>의 값을 다시 참조합니다. 따라서 변경 내용이 SortedList<TKey,TValue> 계속 에 반영됩니다 IList<T>.
속성에서 반환된 Values 컬렉션은 인덱스별로 값을 검색하는 효율적인 방법을 제공합니다. 목록이 값의 내부 배열에 대한 래퍼이기 때문에 속성에 액세스할 때 목록을 다시 생성할 필요가 없습니다. 다음 코드에서는 정렬된 문자열 목록에서 값의 인덱싱된 검색에 속성을 사용하는 Values 방법을 보여 줍니다.
string v = mySortedList.Values[3];
Dim v As String = mySortedList.Values(3)
let v = mySortedList.Values[3]
이 속성의 값을 검색하는 것은 O(1) 작업입니다.