Public ReadOnly Property Values As ValueCollection
Dim instance As SortedDictionary(Of TKey, TValue) Dim value As ValueCollection value = instance.Values
public ValueCollection Values { get; }
public: property ValueCollection^ Values { ValueCollection^ get (); }
/** @property */ public ValueCollection get_Values ()
public function get Values () : ValueCollection
SortedDictionary.ValueCollection 中的值根据 Comparer 属性进行排序,并且与 Keys 属性所返回的 SortedDictionary.KeyCollection 中的关联键具有相同的顺序。
返回的 SortedDictionary.ValueCollection 不是静态副本;相反,SortedDictionary.ValueCollection 反向引用原始 SortedDictionary 中的值。因此,对 SortedDictionary 的更改将继续反映到 SortedDictionary.ValueCollection 中。
获取此属性的值的运算复杂度为 O(1)。
此代码示例演示如何使用 Values 属性枚举字典中的值,并演示如何枚举字典中的键和值。
此代码示例摘自一个为 SortedDictionary 类提供的更大的示例。
' To get the values alone, use the Values property. Dim valueColl _ As SortedDictionary(Of String, String).ValueCollection = _ 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 valueColl Console.WriteLine("Value = {0}", s) Next s <br /><span space="preserve">...</span><br /> ' 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
// To get the values alone, use the Values property. SortedDictionary<string, string>.ValueCollection valueColl = 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 valueColl ) { Console.WriteLine("Value = {0}", s); } <br /><span space="preserve">...</span><br /> // 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); }
Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。