IDictionary.Keys IDictionary.Keys IDictionary.Keys IDictionary.Keys Property

정의

ICollection 개체의 키를 포함하는 IDictionary 개체를 가져옵니다.Gets an ICollection object containing the keys of the IDictionary object.

public:
 property System::Collections::ICollection ^ Keys { System::Collections::ICollection ^ get(); };
public System.Collections.ICollection Keys { get; }
member this.Keys : System.Collections.ICollection
Public ReadOnly Property Keys As ICollection

속성 값

ICollection 개체의 키를 포함하는 IDictionary 개체입니다.An ICollection object containing the keys of the IDictionary object.

예제

다음 코드 예제를 구현 하는 방법에 설명 합니다 Keys 속성입니다.The following code example demonstrates how to implement the Keys property. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 IDictionary 클래스입니다.This code example is part of a larger example provided for the IDictionary class.

public:
    virtual property ICollection^ Keys
    {
        ICollection^ get()
        {
            // Return an array where each item is a key.
            array<Object^>^ keys = gcnew array<Object^>(itemsInUse);
            for (int i = 0; i < itemsInUse; i++)
            {
                keys[i] = items[i]->Key;
            }
            return keys;
        }
    }
public ICollection Keys
{
    get
    {
        // Return an array where each item is a key.
        Object[] keys = new Object[ItemsInUse];
        for (Int32 n = 0; n < ItemsInUse; n++)
            keys[n] = items[n].Key;
        return keys;
    }
}
Public ReadOnly Property Keys() As ICollection Implements IDictionary.Keys
    Get

        ' Return an array where each item is a key.
        ' Note: Declaring keyArray() to have a size of ItemsInUse - 1
        '       ensures that the array is properly sized, in VB.NET
        '       declaring an array of size N creates an array with
        '       0 through N elements, including N, as opposed to N - 1
        '       which is the default behavior in C# and C++.
        Dim keyArray() As Object = New Object(ItemsInUse - 1) {}
        Dim n As Integer
        For n = 0 To ItemsInUse - 1
            keyArray(n) = items(n).Key
        Next n

        Return keyArray
    End Get
End Property

설명

반환 된 키의 순서 ICollection 개체가 지정 되지 않지만 해당 값과 같은 순서로 정렬 되도록 보장 됩니다 합니다 ICollection 반환한는 Values 속성입니다.The order of the keys in the returned ICollection object is unspecified, but is guaranteed to be the same order as the corresponding values in the ICollection returned by the Values property.

적용 대상

추가 정보