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
派生
属性
実装

次の例は、さまざまな関数を作成、初期化、実行する 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.Equalsメソッド (またはIHashCodeProviderインターフェイス) をオーバーライドObject.GetHashCodeするには、a Hashtable によってキーとして使用されるオブジェクトがIComparer必要です。 メソッドとインターフェイスの両方の実装では、大文字と小文字の区別を同じ方法で処理する必要があります。そうしないと、 Hashtable 正しく動作しない可能性があります。 たとえば、クラスを作成するときはHashtable、クラス (または大文字と小文字をCaseInsensitiveHashCodeProvider区別しない実装) をクラス (または大文字と小文字をCaseInsensitiveComparer区別IHashCodeProviderしないIComparer実装) を使用する必要があります。

さらに、これらのメソッドは、キー Hashtableが . 別の方法として、パラメーターを指定して Hashtable コンストラクターを IEqualityComparer 使用することもできます。 キーの等価性が単に参照等価である場合は、継承された実装でObject.GetHashCodeObject.Equals十分です。

キー オブジェクトは、キーとして使用されている限り、不変である必要があります。Hashtable

要素が追加 Hashtableされると、要素はキーのハッシュ コードに基づいてバケットに配置されます。 キーの後続の検索では、キーのハッシュ コードを使用して 1 つの特定のバケットのみを検索するため、要素を検索するために必要なキー比較の数が大幅に減ります。

a Hashtable の読み込み係数によって、バケットに対する要素の最大比率が決まります。 読み込み係数が小さいと、平均検索時間が速くなり、メモリ消費量が増加します。 通常、既定の負荷係数 1.0 は、速度とサイズの最適なバランスを提供します。 また、作成時に別の負荷係数を Hashtable 指定することもできます。

要素が a Hashtableに追加されると、実際の負荷係数が Hashtable 増加します。 実際の負荷係数が指定された負荷係数に達すると、そのバケット Hashtable の数は、現在 Hashtable のバケット数の 2 倍を超える最小素数に自動的に増加します。

内の Hashtable 各キー オブジェクトは、呼び出すことによって GetHashアクセスできる独自のハッシュ関数を提供する必要があります。 ただし、実装 IHashCodeProvider するオブジェクトはコンストラクターに Hashtable 渡すことができます。そのハッシュ関数はテーブル内のすべてのオブジェクトに使用されます。

Hashtableの容量は、Hashtableが保持できる要素の数です。 要素が A Hashtableに追加されると、再割り当てによって必要に応じて容量が自動的に増加します。

.NET Frameworkのみ: 非常に大きなHashtableオブジェクトの場合、構成要素の属性 <gcAllowVeryLargeObjects>を実行時環境に設定enabledすることで、64 ビット システムで最大容量を 20 億要素にtrue増やすことができます。

C# 言語のステートメント (For EachVisual 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 列挙子のラッパーであり、コレクションからの読み取りのみが許可され、コレクションへの書き込みは許可されません。

a の 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)

指定した Hashtable オブジェクトと SerializationInfo オブジェクトを使用してシリアル化できる、StreamingContext クラスの新しい空のインスタンスを初期化します。

プロパティ

comparer
互換性のために残されています。
互換性のために残されています。

IComparer で使用する Hashtable を取得または設定します。

Count

Hashtable に格納されているキー/値ペアの数を取得します。

EqualityComparer

IEqualityComparer に使用する Hashtable を取得します。

hcp
互換性のために残されています。
互換性のために残されています。

ハッシュ コードを提供できるオブジェクトを取得または設定します。

IsFixedSize

Hashtable が固定サイズかどうかを示す値を取得します。

IsReadOnly

Hashtable が読み取り専用かどうかを示す値を取得します。

IsSynchronized

Hashtable へのアクセスが同期されている (スレッド セーフである) かどうかを示す値を取得します。

Item[Object]

指定されたキーに関連付けられている値を取得または設定します。

Keys

Hashtable 内のキーを格納している ICollection を取得します。

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)

1 次元の Hashtable インスタンスの指定したインデックスに Array の要素をコピーします。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetEnumerator()

Hashtable を反復処理する IDictionaryEnumerator を返します。

GetHash(Object)

指定したキーのハッシュ コードを返します。

GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetObjectData(SerializationInfo, StreamingContext)

ISerializable インターフェイスを実装し、Hashtable をシリアル化するために必要なデータを返します。

GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
KeyEquals(Object, Object)

特定の ObjectHashtable 内の特定のキーと比較します。

MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
OnDeserialization(Object)

ISerializable インターフェイスを実装し、逆シリアル化が完了したときに逆シリアル化イベントを発生させます。

Remove(Object)

指定したキーを持つ要素を Hashtable から削除します。

Synchronized(Hashtable)

Hashtable 用の同期された (スレッド セーフな) ラッパーを返します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

IEnumerable.GetEnumerator()

コレクションを反復処理する列挙子を返します。

拡張メソッド

Cast<TResult>(IEnumerable)

IEnumerable の要素を、指定した型にキャストします。

OfType<TResult>(IEnumerable)

指定された型に基づいて IEnumerable の要素をフィルター処理します。

AsParallel(IEnumerable)

クエリの並列化を有効にします。

AsQueryable(IEnumerable)

IEnumerableIQueryable に変換します。

適用対象

スレッド セーフ

Hashtable は、複数のリーダー スレッドと 1 つの書き込みスレッドで使用できるスレッド セーフです。 1 つのスレッドのみが書き込み (更新) 操作を実行する場合、マルチスレッドで使用するスレッド セーフです。これにより、ライターをシリアル化 Hashtableする場合にロックフリーの読み取りが可能になります。 複数のライターをサポートするには、オブジェクトを Hashtable 読み取るスレッドが存在しない場合、メソッドによって Synchronized(Hashtable) 返されるラッパーを介してすべての操作を実行する Hashtable 必要があります。

コレクションの列挙は、本質的にスレッド セーフな手続きではありません。 コレクションが同期されていても、他のスレッドがコレクションを変更する場合があり、このときは列挙子から例外がスローされます。 列挙処理を確実にスレッド セーフに行うには、列挙中にコレクションをロックするか、他のスレッドによって行われた変更によってスローされる例外をキャッチします。

こちらもご覧ください