DictionaryEntry DictionaryEntry DictionaryEntry DictionaryEntry Struct

정의

설정하거나 검색할 수 있는 사전 키/값 쌍을 정의합니다.Defines a dictionary key/value pair that can be set or retrieved.

public value class DictionaryEntry
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public struct DictionaryEntry
type DictionaryEntry = struct
Public Structure DictionaryEntry
상속
DictionaryEntryDictionaryEntryDictionaryEntryDictionaryEntry
특성

예제

다음 예제에서는의 사용을 보여 줍니다 DictionaryEntry 반복 하는 Hashtable 개체입니다.The following example demonstrates the use of DictionaryEntry to iterate through a Hashtable object.

// A simple example for the DictionaryEntry structure.
using namespace System;
using namespace System::Collections;

public ref class Example
{
public:
    static void Main()
    {
        // Create a new hash table.
        //
        Hashtable^ openWith = gcnew Hashtable();

        // Add some elements to the hash table. There are no
        // duplicate keys, but some of the values are duplicates.
        openWith->Add("txt", "notepad.exe");
        openWith->Add("bmp", "paint.exe");
        openWith->Add("dib", "paint.exe");
        openWith->Add("rtf", "wordpad.exe");

        // When you use foreach to enumerate hash table elements,
        // the elements are retrieved as DictionaryEntry objects.
        Console::WriteLine();
        for each (DictionaryEntry de in openWith)
        {
            Console::WriteLine("Key = {0}, Value = {1}", de.Key, de.Value);
        }
    }
};

int main()
{
    Example::Main();
}

/* This code example produces output similar to the following:

Key = rtf, Value = wordpad.exe
Key = txt, Value = notepad.exe
Key = dib, Value = paint.exe
Key = bmp, Value = paint.exe
 */
// A simple example for the DictionaryEntry structure.
using System;
using System.Collections;

class Example
{
    public static void Main()
    {
        // Create a new hash table.
        //
        Hashtable openWith = new Hashtable();

        // Add some elements to the hash table. There are no 
        // duplicate keys, but some of the values are duplicates.
        openWith.Add("txt", "notepad.exe");
        openWith.Add("bmp", "paint.exe");
        openWith.Add("dib", "paint.exe");
        openWith.Add("rtf", "wordpad.exe");

        // When you use foreach to enumerate hash table elements,
        // the elements are retrieved as DictionaryEntry objects.
        Console.WriteLine();
        foreach (DictionaryEntry de in openWith)
        {
            Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value);
        }
    }
}

/* This code example produces output similar to the following:

Key = rtf, Value = wordpad.exe
Key = txt, Value = notepad.exe
Key = dib, Value = paint.exe
Key = bmp, Value = paint.exe
 */
'A simple example for the DictionaryEntry structure.
Imports System
Imports System.Collections
Imports Microsoft.VisualBasic

Module Example

    Sub Main()

        ' Create a new hash table.
        '
        Dim openWith As New Hashtable()

        ' Add some elements to the hash table. There are no
        ' duplicate keys, but some of the values are duplicates.
        openWith.Add("txt", "notepad.exe")
        openWith.Add("bmp", "paint.exe")
        openWith.Add("dib", "paint.exe")
        openWith.Add("rtf", "wordpad.exe")

        ' When you use For Each to enumerate hash table elements,
        ' the elements are retrieved as DictionaryEntry objects.
        Console.WriteLine()
        For Each de As DictionaryEntry In openWith
            Console.WriteLine("Key = {0}, Value = {1}", _
                de.Key, de.Value)
        Next de

    End Sub

End Module

' This code example produces output similar to the following:
'
'Key = rtf, Value = wordpad.exe
'Key = txt, Value = notepad.exe
'Key = dib, Value = paint.exe
'Key = bmp, Value = paint.exe

설명

IDictionaryEnumerator.Entry 메서드가 형식의 인스턴스를 반환 합니다.The IDictionaryEnumerator.Entry method returns an instance of this type.

중요

사용 하는 권장 하지 않습니다는 DictionaryEntry 새로운 개발에 대 한 구조입니다.We don't recommend that you use the DictionaryEntry structure for new development. 대신, 제네릭을 사용 하는 좋습니다 KeyValuePair<TKey,TValue> 와 함께 구조체는 Dictionary<TKey,TValue> 클래스.Instead, we recommend that you use a generic KeyValuePair<TKey,TValue> structure along with the Dictionary<TKey,TValue> class. 자세한 내용은 제네릭이 아닌 컬렉션을 사용 하지 않아야 github입니다.For more information, see Non-generic collections shouldn't be used on GitHub.

C# foreach 문 및 Visual Basic 마다 문에 필요한 컬렉션에 있는 각 요소의 형식입니다.The C# foreach statement and the Visual Basic For Each statement require the type of each element in the collection. 각 요소의 이후는 IDictionary 는 키/값 쌍은 요소 형식이 키의 형식 또는 값의 형식입니다.Since each element of the IDictionary is a key/value pair, the element type is not the type of the key or the type of the value. 요소 형식은 대신 DictionaryEntry합니다.Instead, the element type is DictionaryEntry. 예:For example:

for each (DictionaryEntry de in openWith)
{
    Console::WriteLine("Key = {0}, Value = {1}", de.Key, de.Value);
}
foreach (DictionaryEntry de in openWith)
{
    Console.WriteLine("Key = {0}, Value = {1}", de.Key, de.Value);
}
For Each de As DictionaryEntry In openWith
    Console.WriteLine("Key = {0}, Value = {1}", _
        de.Key, de.Value)
Next de

foreach 문을 열거자를 컬렉션에 쓰는 것부터 읽기 가능 래퍼입니다.The foreach statement is a wrapper around the enumerator, which only allows reading from, not writing to, the collection.

생성자

DictionaryEntry(Object, Object) DictionaryEntry(Object, Object) DictionaryEntry(Object, Object) DictionaryEntry(Object, Object)

지정된 키와 값을 사용하여 DictionaryEntry 형식의 인스턴스를 초기화합니다.Initializes an instance of the DictionaryEntry type with the specified key and value.

속성

Key Key Key Key

키/값 쌍에서 키를 가져오거나 설정합니다.Gets or sets the key in the key/value pair.

Value Value Value Value

키/값 쌍에서 값을 가져오거나 설정합니다.Gets or sets the value in the key/value pair.

메서드

Deconstruct(Object, Object) Deconstruct(Object, Object) Deconstruct(Object, Object) Deconstruct(Object, Object)

적용 대상

추가 정보