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) 操作。