Hashtable 클래스

정의

키의 해시 코드에 따라 구성된 키/값 쌍의 컬렉션을 나타냅니다.

public ref class Hashtable : System::Collections::IDictionary
public ref class Hashtable : ICloneable, System::Collections::IDictionary, System::Runtime::Serialization::IDeserializationCallback, System::Runtime::Serialization::ISerializable
public class Hashtable : System.Collections.IDictionary
public class Hashtable : ICloneable, System.Collections.IDictionary, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
[System.Serializable]
public class Hashtable : ICloneable, System.Collections.IDictionary, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class Hashtable : ICloneable, System.Collections.IDictionary, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
type Hashtable = class
    interface ICollection
    interface IEnumerable
    interface IDictionary
type Hashtable = class
    interface ICollection
    interface IEnumerable
    interface IDictionary
    interface ICloneable
    interface IDeserializationCallback
    interface ISerializable
type Hashtable = class
    interface ICollection
    interface IEnumerable
    interface IDictionary
    interface ISerializable
    interface IDeserializationCallback
    interface ICloneable
[<System.Serializable>]
type Hashtable = class
    interface IDictionary
    interface ICollection
    interface IEnumerable
    interface ISerializable
    interface IDeserializationCallback
    interface ICloneable
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Hashtable = class
    interface IDictionary
    interface ICollection
    interface IEnumerable
    interface ISerializable
    interface IDeserializationCallback
    interface ICloneable
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Hashtable = class
    interface IDictionary
    interface ISerializable
    interface IDeserializationCallback
    interface ICloneable
    interface ICollection
    interface IEnumerable
Public Class Hashtable
Implements IDictionary
Public Class Hashtable
Implements ICloneable, IDeserializationCallback, IDictionary, ISerializable
상속
Hashtable
파생
특성
구현

예제

다음 예제에서는 A에 다양한 함수 Hashtable 를 만들고, 초기화하고, 수행하는 방법과 해당 키와 값을 출력하는 방법을 보여 줍니다.

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");

        // The Add method throws an exception if the new key is 
        // already in the hash table.
        try
        {
            openWith->Add("txt", "winword.exe");
        }
        catch(...)
        {
            Console::WriteLine("An element with Key = \"txt\" already exists.");
        }

        // The Item property is the default property, so you 
        // can omit its name when accessing elements. 
        Console::WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]);
        
        // The default Item property can be used to change the value
        // associated with a key.
        openWith["rtf"] = "winword.exe";
        Console::WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]);

        // If a key does not exist, setting the default Item property
        // for that key adds a new key/value pair.
        openWith["doc"] = "winword.exe";

        // ContainsKey can be used to test keys before inserting 
        // them.
        if (!openWith->ContainsKey("ht"))
        {
            openWith->Add("ht", "hypertrm.exe");
            Console::WriteLine("Value added for key = \"ht\": {0}", openWith["ht"]);
        }

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

        // To get the values alone, use the Values property.
        ICollection^ valueColl = openWith->Values;
        
        // The elements of the ValueCollection are strongly typed
        // with the type that was specified for hash table values.
        Console::WriteLine();
        for each( String^ s in valueColl )
        {
            Console::WriteLine("Value = {0}", s);
        }

        // To get the keys alone, use the Keys property.
        ICollection^ keyColl = openWith->Keys;
        
        // The elements of the KeyCollection are strongly typed
        // with the type that was specified for hash table keys.
        Console::WriteLine();
        for each( String^ s in keyColl )
        {
            Console::WriteLine("Key = {0}", s);
        }

        // Use the Remove method to remove a key/value pair.
        Console::WriteLine("\nRemove(\"doc\")");
        openWith->Remove("doc");

        if (!openWith->ContainsKey("doc"))
        {
            Console::WriteLine("Key \"doc\" is not found.");
        }
    }
};

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

/* This code example produces the following output:

An element with Key = "txt" already exists.
For key = "rtf", value = wordpad.exe.
For key = "rtf", value = winword.exe.
Value added for key = "ht": hypertrm.exe

Key = dib, Value = paint.exe
Key = txt, Value = notepad.exe
Key = ht, Value = hypertrm.exe
Key = bmp, Value = paint.exe
Key = rtf, Value = winword.exe
Key = doc, Value = winword.exe

Value = paint.exe
Value = notepad.exe
Value = hypertrm.exe
Value = paint.exe
Value = winword.exe
Value = winword.exe

Key = dib
Key = txt
Key = ht
Key = bmp
Key = rtf
Key = doc

Remove("doc")
Key "doc" is not found.
 */
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");

        // The Add method throws an exception if the new key is
        // already in the hash table.
        try
        {
            openWith.Add("txt", "winword.exe");
        }
        catch
        {
            Console.WriteLine("An element with Key = \"txt\" already exists.");
        }

        // The Item property is the default property, so you
        // can omit its name when accessing elements.
        Console.WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]);

        // The default Item property can be used to change the value
        // associated with a key.
        openWith["rtf"] = "winword.exe";
        Console.WriteLine("For key = \"rtf\", value = {0}.", openWith["rtf"]);

        // If a key does not exist, setting the default Item property
        // for that key adds a new key/value pair.
        openWith["doc"] = "winword.exe";

        // ContainsKey can be used to test keys before inserting
        // them.
        if (!openWith.ContainsKey("ht"))
        {
            openWith.Add("ht", "hypertrm.exe");
            Console.WriteLine("Value added for key = \"ht\": {0}", openWith["ht"]);
        }

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

        // To get the values alone, use the Values property.
        ICollection valueColl = openWith.Values;

        // The elements of the ValueCollection are strongly typed
        // with the type that was specified for hash table values.
        Console.WriteLine();
        foreach( string s in valueColl )
        {
            Console.WriteLine("Value = {0}", s);
        }

        // To get the keys alone, use the Keys property.
        ICollection keyColl = openWith.Keys;

        // The elements of the KeyCollection are strongly typed
        // with the type that was specified for hash table keys.
        Console.WriteLine();
        foreach( string s in keyColl )
        {
            Console.WriteLine("Key = {0}", s);
        }

        // Use the Remove method to remove a key/value pair.
        Console.WriteLine("\nRemove(\"doc\")");
        openWith.Remove("doc");

        if (!openWith.ContainsKey("doc"))
        {
            Console.WriteLine("Key \"doc\" is not found.");
        }
    }
}

/* This code example produces the following output:

An element with Key = "txt" already exists.
For key = "rtf", value = wordpad.exe.
For key = "rtf", value = winword.exe.
Value added for key = "ht": hypertrm.exe

Key = dib, Value = paint.exe
Key = txt, Value = notepad.exe
Key = ht, Value = hypertrm.exe
Key = bmp, Value = paint.exe
Key = rtf, Value = winword.exe
Key = doc, Value = winword.exe

Value = paint.exe
Value = notepad.exe
Value = hypertrm.exe
Value = paint.exe
Value = winword.exe
Value = winword.exe

Key = dib
Key = txt
Key = ht
Key = bmp
Key = rtf
Key = doc

Remove("doc")
Key "doc" is not found.
 */
Imports System.Collections

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")

        ' The Add method throws an exception if the new key is 
        ' already in the hash table.
        Try
            openWith.Add("txt", "winword.exe")
        Catch
            Console.WriteLine("An element with Key = ""txt"" already exists.")
        End Try

        ' The Item property is the default property, so you 
        ' can omit its name when accessing elements. 
        Console.WriteLine("For key = ""rtf"", value = {0}.", _
            openWith("rtf"))

        ' The default Item property can be used to change the value
        ' associated with a key.
        openWith("rtf") = "winword.exe"
        Console.WriteLine("For key = ""rtf"", value = {0}.", _
            openWith("rtf"))

        ' If a key does not exist, setting the default Item property
        ' for that key adds a new key/value pair.
        openWith("doc") = "winword.exe"

        ' ContainsKey can be used to test keys before inserting 
        ' them.
        If Not openWith.ContainsKey("ht") Then
            openWith.Add("ht", "hypertrm.exe")
            Console.WriteLine("Value added for key = ""ht"": {0}", _
                openWith("ht"))
        End If

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

        ' To get the values alone, use the Values property.
        Dim valueColl As ICollection = openWith.Values

        ' The elements of the ValueCollection are strongly typed
        ' with the type that was specified for hash table values.
        Console.WriteLine()
        For Each s As String In valueColl
            Console.WriteLine("Value = {0}", s)
        Next s

        ' To get the keys alone, use the Keys property.
        Dim keyColl As ICollection = openWith.Keys

        ' The elements of the KeyCollection are strongly typed
        ' with the type that was specified for hash table keys.
        Console.WriteLine()
        For Each s As String In keyColl
            Console.WriteLine("Key = {0}", s)
        Next s

        ' Use the Remove method to remove a key/value pair.
        Console.WriteLine(vbLf + "Remove(""doc"")")
        openWith.Remove("doc")

        If Not openWith.ContainsKey("doc") Then
            Console.WriteLine("Key ""doc"" is not found.")
        End If

    End Sub

End Module

' This code example produces the following output:
'
'An element with Key = "txt" already exists.
'For key = "rtf", value = wordpad.exe.
'For key = "rtf", value = winword.exe.
'Value added for key = "ht": hypertrm.exe
'
'Key = dib, Value = paint.exe
'Key = txt, Value = notepad.exe
'Key = ht, Value = hypertrm.exe
'Key = bmp, Value = paint.exe
'Key = rtf, Value = winword.exe
'Key = doc, Value = winword.exe
'
'Value = paint.exe
'Value = notepad.exe
'Value = hypertrm.exe
'Value = paint.exe
'Value = winword.exe
'Value = winword.exe
'
'Key = dib
'Key = txt
'Key = ht
'Key = bmp
'Key = rtf
'Key = doc
'
'Remove("doc")
'Key "doc" is not found.
# Create new hash table using PowerShell syntax
$OpenWith = @{}

# Add one element to the hash table using the Add method
$OpenWith.Add('txt', 'notepad.exe')

# Add three eleements using PowerShell syntax three different ways
$OpenWith.dib = 'paint.exe'

$KeyBMP = 'bmp'
$OpenWith[$KeyBMP] = 'paint.exe'

$OpenWith += @{'rtf' = 'wordpad.exe'}

# Display hash table
"There are {0} in the `$OpenWith hash table as follows:" -f $OpenWith.Count
''

# Display hashtable properties
'Count of items in the hashtable  : {0}' -f $OpenWith.Count
'Is hashtable fixed size?         : {0}' -f $OpenWith.IsFixedSize
'Is hashtable read-only?          : {0}' -f $OpenWith.IsReadonly
'Is hashtabale synchronised?      : {0}' -f $OpenWith.IsSynchronized
''
'Keys in hashtable:'
$OpenWith.Keys
''
'Values in hashtable:'
$OpenWith.Values
''

<#
This script produces the following output:

There are 4 in the $OpenWith hash table as follows:

Name                           Value                                                                            
----                           -----                                                                            
txt                            notepad.exe                                                                      
dib                            paint.exe                                                                        
bmp                            paint.exe                                                                        
rtf                            wordpad.exe                                                                      

Count of items in the hashtable  : 4
Is hashtable fixed size?         : False
Is hashtable read-only?          : False
Is hashtabale synchronised?      : False

Keys in hashtable:
txt
dib
bmp
rtf

Values in hashtable:
notepad.exe
paint.exe
paint.exe
wordpad.exe
#>

설명

각 요소는 개체에 저장된 키/값 쌍입니다 DictionaryEntry . 키는 사용할 null수 없지만 값이 될 수 있습니다.

중요

새 개발에 클래스를 Hashtable 사용하지 않는 것이 좋습니다. 대신 제네릭 Dictionary<TKey,TValue> 클래스를 사용하는 것이 좋습니다. 자세한 내용은 GitHub 사용할 수 없는 제네릭이 아닌 컬렉션을 참조하세요.

메서드(또는 인터페이스) 및 메서드(또는 인터페이스)를 재정 Object.GetHashCodeObject.Equals IHashCodeProvider 하려면 키 Hashtable 로 사용되는 개체가 IComparer 필요합니다. 메서드와 인터페이스의 구현은 대/소문자 구분을 동일한 방식으로 처리해야 합니다. 그렇지 않으면 잘못 동작할 Hashtable 수 있습니다. 예를 들어 만들 Hashtable때 클래스(또는 대/소문자를 구분 IHashCodeProvider 하지 않는 구현)와 CaseInsensitiveComparer 클래스(또는 대/소문자를 구분 IComparer 하지 않는 구현)를 사용해야 CaseInsensitiveHashCodeProvider 합니다.

또한 이러한 메서드는 키가 Hashtable있는 동안 동일한 매개 변수를 사용하여 호출될 때 동일한 결과를 생성해야 합니다. 다른 방법은 매개 변수와 Hashtable 함께 생성자를 사용하는 것입니다 IEqualityComparer . 키 같음이 단순히 참조 같음인 경우 상속된 구현으로 Object.GetHashCode 충분합니다 Object.Equals .

키 개체는 .에서 Hashtable키로 사용되는 한 변경할 수 없어야 합니다.

요소가 추가 Hashtable되면 요소는 키의 해시 코드에 따라 버킷에 배치됩니다. 키의 후속 조회는 키의 해시 코드를 사용하여 하나의 특정 버킷에서만 검색하므로 요소를 찾는 데 필요한 키 비교 수를 크게 줄입니다.

부하 계수는 Hashtable 버킷에 대한 요소의 최대 비율을 결정합니다. 부하 요인이 작을수록 메모리 사용량이 늘어나면 평균 조회 시간이 더 빨라집니다. 1.0의 기본 부하 요소는 일반적으로 속도와 크기 간의 최상의 균형을 제공합니다. 다른 로드 팩터를 만들 때 Hashtable 지정할 수도 있습니다.

요소가 추가 Hashtable되면 실제 로드 요소가 Hashtable 증가합니다. 실제 부하 요소가 지정된 부하 계수에 Hashtable 도달하면 버킷 수가 현재 Hashtable 버킷 수의 두 배보다 큰 가장 작은 소수로 자동으로 증가합니다.

의 각 키 개체는 Hashtable 호출 GetHash을 통해 액세스할 수 있는 자체 해시 함수를 제공해야 합니다. 그러나 구현하는 모든 개체를 IHashCodeProvider 생성자에 전달할 Hashtable 수 있으며 해당 해시 함수는 테이블의 모든 개체에 사용됩니다.

용량은 Hashtable 보유할 수 있는 Hashtable 요소의 수입니다. 요소가 추가 Hashtable되면 재할당을 통해 필요에 따라 용량이 자동으로 증가합니다.

.NET Framework 전용: 매우 큰 Hashtable 개체의 경우 구성 요소의 <gcAllowVeryLargeObjects> 특성을 런타임 환경에서 설정 enabled 하여 64비트 시스템에서 최대 용량을 20억 요소로 true 늘릴 수 있습니다.

C# 언어For Each(Visual Basic)의 문은 foreach 컬렉션에 있는 요소 형식의 개체를 반환합니다. 각 요소는 Hashtable 키/값 쌍이므로 요소 형식은 키의 형식이나 값의 형식이 아닙니다. 대신 요소 형식은 .입니다 DictionaryEntry. 예를 들면 다음과 같습니다.

for each(DictionaryEntry de in myHashtable)
{
    // ...
}
foreach(DictionaryEntry de in myHashtable)
{
    // ...
}
For Each de As DictionaryEntry In myHashtable
    ' ...
Next de

foreach 문은 열거자 주위에 있는 래퍼로, 컬렉션을 쓰는 것이 아니라 읽기만 허용합니다.

열거자를 Hashtable 직렬화 및 역직렬화하면 요소의 순서가 다시 지정될 수 있으므로 메서드를 호출 Reset 하지 않고는 열거를 계속할 수 없습니다.

참고

키를 상속하고 동작을 변경할 수 있으므로 메서드를 사용한 비교를 통해 Equals 절대 고유성을 보장할 수 없습니다.

생성자

Hashtable()

기본 초기 용량, 로드 비율, 해시 코드 공급자 및 비교자를 사용하여 Hashtable 클래스의 비어 있는 새 인스턴스를 초기화합니다.

Hashtable(IDictionary)

지정한 사전의 요소를 새 Hashtable 개체에 복사하여 Hashtable 클래스의 새 인스턴스를 초기화합니다. 새 Hashtable 개체는 복사된 요소 수와 같은 초기 용량을 갖고 있고 기본 로드 비율, 해시 코드 공급자 및 비교자를 사용합니다.

Hashtable(IDictionary, IEqualityComparer)

지정된 사전의 요소를 새 Hashtable 개체에 복사하여 Hashtable 클래스의 새 인스턴스를 초기화합니다. 새 Hashtable 개체는 복사된 요소 수와 같은 초기 용량을 갖고 있고 기본 로드 비율과 지정된 IEqualityComparer 개체를 사용합니다.

Hashtable(IDictionary, IHashCodeProvider, IComparer)
사용되지 않습니다.
사용되지 않습니다.

지정한 사전의 요소를 새 Hashtable 개체에 복사하여 Hashtable 클래스의 새 인스턴스를 초기화합니다. 새 Hashtable 개체는 복사된 요소 수와 같은 초기 용량을 갖고 있고 기본 로드 비율과 지정된 해시 코드 공급자 및 비교자를 사용합니다. 이 API는 더 이상 사용되지 않습니다. 다른 방법을 보려면 Hashtable(IDictionary, IEqualityComparer)를 참조하십시오.

Hashtable(IDictionary, Single)

지정한 사전의 요소를 새 Hashtable 개체에 복사하여 Hashtable 클래스의 새 인스턴스를 초기화합니다. 새 Hashtable 개체는 복사된 요소 수와 같은 초기 용량을 갖고 있고 지정된 로드 비율과 기본 해시 코드 공급자 및 비교자를 사용합니다.

Hashtable(IDictionary, Single, IEqualityComparer)

지정한 사전의 요소를 새 Hashtable 개체에 복사하여 Hashtable 클래스의 새 인스턴스를 초기화합니다. 새 Hashtable 개체는 복사된 요소 수와 같은 초기 용량을 갖고 있고 지정된 로드 비율 및 IEqualityComparer 개체를 사용합니다.

Hashtable(IDictionary, Single, IHashCodeProvider, IComparer)
사용되지 않습니다.
사용되지 않습니다.

지정한 사전의 요소를 새 Hashtable 개체에 복사하여 Hashtable 클래스의 새 인스턴스를 초기화합니다. 새 Hashtable 개체는 복사된 요소 수와 같은 초기 용량을 갖고 있고 지정된 로드 비율, 해시 코드 공급자 및 비교자를 사용합니다.

Hashtable(IEqualityComparer)

기본 초기 용량 및 로드 비율과 지정된 Hashtable 개체를 사용하여 IEqualityComparer 클래스의 비어 있는 새 인스턴스를 초기화합니다.

Hashtable(IHashCodeProvider, IComparer)
사용되지 않습니다.
사용되지 않습니다.
사용되지 않습니다.

기본 초기 용량 및 로드 비율과 지정된 해시 코드 공급자 및 비교자를 사용하여 Hashtable 클래스의 비어 있는 새 인스턴스를 초기화합니다.

Hashtable(Int32)

지정된 초기 용량과 기본 로드 비율, 해시 코드 공급자 및 비교자를 사용하여 Hashtable 클래스의 비어 있는 새 인스턴스를 초기화합니다.

Hashtable(Int32, IEqualityComparer)

지정된 초기 용량 및 Hashtable와 기본 로드 비율을 사용하여 IEqualityComparer 클래스의 비어 있는 새 인스턴스를 초기화합니다.

Hashtable(Int32, IHashCodeProvider, IComparer)
사용되지 않습니다.
사용되지 않습니다.

지정된 초기 용량, 해시 코드 공급자 및 비교자와 기본 로드 비율을 사용하여 Hashtable 클래스의 비어 있는 새 인스턴스를 초기화합니다.

Hashtable(Int32, Single)

지정된 초기 용량 및 로드 비율과 기본 해시 코드 공급자 및 비교자를 사용하여 Hashtable 클래스의 비어 있는 새 인스턴스를 초기화합니다.

Hashtable(Int32, Single, IEqualityComparer)

지정된 초기 용량, 로드 비율 및 Hashtable 개체를 사용하여 IEqualityComparer 클래스의 비어 있는 새 인스턴스를 초기화합니다.

Hashtable(Int32, Single, IHashCodeProvider, IComparer)
사용되지 않습니다.
사용되지 않습니다.

지정된 초기 용량, 로드 비율, 해시 코드 공급자 및 비교자를 사용하여 Hashtable 클래스의 비어 있는 새 인스턴스를 초기화합니다.

Hashtable(SerializationInfo, StreamingContext)

지정된 HashtableSerializationInfo 개체를 사용하여 serialize할 수 있는 StreamingContext 클래스의 비어 있는 새 인스턴스를 초기화합니다.

속성

comparer
사용되지 않습니다.
사용되지 않습니다.

IComparer에 사용할 Hashtable를 가져오거나 설정합니다.

Count

Hashtable에 포함된 키/값 쌍의 수를 가져옵니다.

EqualityComparer

IEqualityComparer에 사용할 Hashtable를 가져옵니다.

hcp
사용되지 않습니다.
사용되지 않습니다.

해시 코드를 분배할 수 있는 개체를 가져오거나 설정합니다.

IsFixedSize

Hashtable의 크기가 고정되어 있는지 여부를 나타내는 값을 가져옵니다.

IsReadOnly

Hashtable가 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

IsSynchronized

Hashtable에 대한 액세스가 동기화되어 스레드로부터 안전하게 보호되는지를 나타내는 값을 가져옵니다.

Item[Object]

지정된 키에 연결된 값을 가져오거나 설정합니다.

Keys

ICollection의 키를 포함하는 Hashtable을 가져옵니다.

SyncRoot

Hashtable에 대한 액세스를 동기화하는 데 사용할 수 있는 개체를 가져옵니다.

Values

ICollection의 값이 들어 있는 Hashtable을 가져옵니다.

메서드

Add(Object, Object)

지정한 키와 값을 가지는 요소를 Hashtable에 추가합니다.

Clear()

Hashtable에서 요소를 모두 제거합니다.

Clone()

Hashtable의 부분 복사본을 만듭니다.

Contains(Object)

Hashtable에 특정 키가 들어 있는지 여부를 확인합니다.

ContainsKey(Object)

Hashtable에 특정 키가 들어 있는지 여부를 확인합니다.

ContainsValue(Object)

Hashtable에 특정 값이 들어 있는지 여부를 확인합니다.

CopyTo(Array, Int32)

Hashtable 요소를 지정한 인덱스의 1차원 Array 인스턴스에 복사합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetEnumerator()

IDictionaryEnumerator를 반복하는 Hashtable를 반환합니다.

GetHash(Object)

지정한 키의 해시 코드를 반환합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetObjectData(SerializationInfo, StreamingContext)

ISerializable 인터페이스를 구현하고 Hashtable을 serialize하는 데 필요한 데이터를 반환합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
KeyEquals(Object, Object)

특정 ObjectHashtable의 특정 키와 비교합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
OnDeserialization(Object)

ISerializable 인터페이스를 구현하고, deserialization이 완료되면 deserialization 이벤트를 발생시킵니다.

Remove(Object)

Hashtable에서 키가 지정된 요소를 제거합니다.

Synchronized(Hashtable)

Hashtable에 대해 동기화되어 스레드로부터 안전하게 보호되는 래퍼를 반환합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

IEnumerable.GetEnumerator()

컬렉션을 반복하는 열거자를 반환합니다.

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

스레드 보안

Hashtable 는 여러 판독기 스레드 및 단일 쓰기 스레드에서 사용하기에 안전한 스레드입니다. 스레드 중 하나만 쓰기(업데이트) 작업을 수행하는 경우 다중 스레드 사용에 대해 스레드로부터 안전하며, 기록기가 직렬화되는 경우 잠금 없는 읽기를 Hashtable허용합니다. 여러 기록기를 지원하려면 개체를 HashtableHashtable 는 스레드가 없는 경우 메서드에서 Synchronized(Hashtable) 반환된 래퍼를 통해 모든 작업을 수행해야 합니다.

컬렉션을 열거 되지 본질적으로 스레드로부터 안전한 프로시저가 있습니다. 컬렉션이 동기화되어 있을 때 다른 스레드에서 해당 컬렉션을 수정할 수 있으므로 이렇게 되면 열거자에서 예외가 throw됩니다. 열거하는 동안 스레드로부터 안전을 보장하려면 전체 열거를 수행하는 동안 컬렉션을 잠그거나 다른 스레드에서 변경된 내용으로 인해 발생한 예외를 catch하면 됩니다.

추가 정보