IDictionary.Values 属性

获取 ICollection 对象,它包含 IDictionary 对象中的值。

**命名空间:**System.Collections
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
ReadOnly Property Values As ICollection
用法
Dim instance As IDictionary
Dim value As ICollection

value = instance.Values
ICollection Values { get; }
property ICollection^ Values {
    ICollection^ get ();
}
/** @property */
ICollection get_Values ()
function get Values () : ICollection

属性值

ICollection 对象,它包含 IDictionary 对象中的值。

备注

未指定返回的 ICollection 对象中的值的顺序,但它与由 Keys 属性返回的 ICollection 中的相应键具有相同的顺序。

示例

下面的代码示例演示如何实现 Values 属性。此代码示例是为 IDictionary 类提供的一个更大示例的一部分。

Public ReadOnly Property Values() As ICollection Implements IDictionary.Values
    Get
        ' Return an array where each item is a value.
        Dim valueArray() As Object = New Object(ItemsInUse - 1) {}
        Dim n As Integer
        For n = 0 To ItemsInUse - 1
            valueArray(n) = items(n).Value
        Next n

        Return valueArray
    End Get
End Property
public ICollection Values
{
    get
    {
        // Return an array where each item is a value.
        Object[] values = new Object[ItemsInUse];
        for (Int32 n = 0; n < ItemsInUse; n++)
            values[n] = items[n].Value;
        return values;
    }
}
public:
    virtual property ICollection^ Values
    {
        ICollection^ get()
        {
            // Return an array where each item is a value.
            array<Object^>^ values = gcnew array<Object^>(itemsInUse);
            for (int i = 0; i < itemsInUse; i++)
            {
                values[i] = items[i]->Value;
            }
            return values;
        }
    }

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

IDictionary 接口
IDictionary 成员
System.Collections 命名空间
ICollection 接口