StringDictionary.Values 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
會得到一組值在 StringDictionary中。
public:
virtual property System::Collections::ICollection ^ Values { System::Collections::ICollection ^ get(); };
public virtual System.Collections.ICollection Values { get; }
member this.Values : System.Collections.ICollection
Public Overridable ReadOnly Property Values As ICollection
屬性值
一個 ICollection 提供 中的 StringDictionary值。
範例
以下程式碼範例列舉了 StringDictionary的元素。
using System;
using System.Collections;
using System.Collections.Specialized;
public class SamplesStringDictionary
{
public static void Main()
{
// Creates and initializes a new StringDictionary.
StringDictionary myCol = new StringDictionary();
myCol.Add( "red", "rojo" );
myCol.Add( "green", "verde" );
myCol.Add( "blue", "azul" );
Console.WriteLine("VALUES");
foreach (string val in myCol.Values)
{
Console.WriteLine(val);
}
}
}
// This code produces the following output.
// VALUES
// verde
// rojo
// azul
Imports System.Collections
Imports System.Collections.Specialized
Public Class SamplesStringDictionary
Public Shared Sub Main()
' Creates and initializes a new StringDictionary.
Dim myCol As New StringDictionary()
myCol.Add( "red", "rojo" )
myCol.Add( "green", "verde" )
myCol.Add( "blue", "azul" )
Console.WriteLine("VALUES")
For Each val As String In myCol.Values
Console.WriteLine(val)
Next val
End Sub
End Class
' This code produces the following output.
'
' VALUES
' verde
' rojo
' azul
備註
中ICollection值的順序未明確,但與方法回傳ICollection的相關鍵Keys順序相同。
回傳 ICollection 的 不是靜態副本;而是 ICollection 回溯到原始 StringDictionary中的值。 因此,變化 StringDictionary 會持續反映在 ICollection中。
取得此性質的值為 O(1) 運算。