dictionary!とは? わかりやすく解説

Dictionary コンストラクタ ()

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

空で、既定初期量を備えキーの型の既定等値比較演算子使用する、Dictionary クラス新しインスタンス初期化します。

名前空間: System.Collections.Generic
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Dim instance As New Dictionary(Of
 TKey, TValue)
public Dictionary ()
public:
Dictionary ()
public Dictionary ()
解説解説
使用例使用例

文字列キーを含む文字列の空の Dictionary作成しAdd メソッド使用していくつかの要素追加するコード例次に示します。この例では、重複するキー追加しようとすると、Add メソッドが ArgumentException をスローすることを示します

このコード例は、Dictionary クラストピック取り上げているコード例一部分です。

' Create a new dictionary of strings, with string keys.
'
Dim openWith As New Dictionary(Of
 String, String)

' Add some elements to the dictionary. 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 dictionary.
Try
    openWith.Add("txt", "winword.exe")
Catch 
    Console.WriteLine("An element with Key = ""txt""
 already exists.")
End Try
// Create a new dictionary of strings, with string keys.
//
Dictionary<string, string> openWith =
 
    new Dictionary<string, string>();

// Add some elements to the dictionary. 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 dictionary.
try
{
    openWith.Add("txt", "winword.exe");
}
catch (ArgumentException)
{
    Console.WriteLine("An element with Key = \"txt\" already exists.");
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Dictionary ジェネリック クラス
Dictionary メンバ
System.Collections.Generic 名前空間
EqualityComparer.Default
IEquatable ジェネリック インターフェイス

Dictionary コンストラクタ

Dictionary クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
Dictionary () 空で、既定初期量を備えキーの型の既定等値比較演算子使用するDictionary クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

Dictionary (ジェネリック IDictionary) 指定した IDictionary から要素コピーして格納しキーの型の既定等値比較演算子使用するDictionary クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

Dictionary (ジェネリック IEqualityComparer) 空で、既定初期量を備え指定した IEqualityComparer を使用するDictionary クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

Dictionary (Int32) 空で、指定した初期量を備えキーの型の既定等値比較演算子使用するDictionary クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

Dictionary (ジェネリック IDictionary, ジェネリック IEqualityComparer) 指定した IDictionary から要素コピーして格納し指定した IEqualityComparer使用するDictionary クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

Dictionary (Int32, ジェネリック IEqualityComparer) 空で、指定した初期量を備え指定した IEqualityComparer使用するDictionary クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

Dictionary (SerializationInfo, StreamingContext) シリアル化したデータ使用してDictionary クラス新しインスタンス初期化します。
参照参照

関連項目

Dictionary ジェネリック クラス
Dictionary メンバ
System.Collections.Generic 名前空間
EqualityComparer.Default
IEquatable ジェネリック インターフェイス

Dictionary コンストラクタ (SerializationInfo, StreamingContext)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

シリアル化したデータ使用してDictionary クラス新しインスタンス初期化します。

名前空間: System.Collections.Generic
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Protected Sub New ( _
    info As SerializationInfo, _
    context As StreamingContext _
)
Dim info As SerializationInfo
Dim context As StreamingContext

Dim instance As New Dictionary(Of
 TKey, TValue)(info, context)
protected Dictionary (
    SerializationInfo info,
    StreamingContext context
)
protected:
Dictionary (
    SerializationInfo^ info, 
    StreamingContext context
)
protected Dictionary (
    SerializationInfo info, 
    StreamingContext context
)
protected function Dictionary (
    info : SerializationInfo, 
    context : StreamingContext
)

パラメータ

info

Dictionary をシリアル化するために必要な情報格納している System.Runtime.Serialization.SerializationInfo オブジェクト

context

Dictionary関連付けられているシリアル化ストリームソースおよびデスティネーション格納している System.Runtime.Serialization.StreamingContext 構造体

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Dictionary ジェネリック クラス
Dictionary メンバ
System.Collections.Generic 名前空間
System.Runtime.Serialization

Dictionary コンストラクタ (ジェネリック IDictionary)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

指定した IDictionary から要素コピーして格納しキーの型の既定等値比較演算子使用するDictionary クラス新しインスタンス初期化します。

名前空間: System.Collections.Generic
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    dictionary As IDictionary(Of TKey, TValue)
 _
)
Dim dictionary As IDictionary(Of
 TKey, TValue)

Dim instance As New Dictionary(Of
 TKey, TValue)(dictionary)
public Dictionary (
    IDictionary<TKey,TValue> dictionary
)
public:
Dictionary (
    IDictionary<TKey, TValue>^ dictionary
)
public Dictionary (
    IDictionary<TKey,TValue> dictionary
)
public function Dictionary (
    dictionary : IDictionary<TKey,TValue>
)

パラメータ

dictionary

新しい Dictionary に要素コピーされた IDictionary。

例外例外
例外種類条件

ArgumentNullException

dictionarynull 参照 (Visual Basic では Nothing) です。

ArgumentException

dictionary に、1 つ上の重複するキー格納されています。

解説解説
使用例使用例

Dictionary(ジェネリック IEqualityComparer) コンストラクタ使用し並べ替えられた別のディクショナリの内容によって Dictionary初期化する方法次のコード例示します。このコード例では、SortedDictionary を作成し、このディクショナリにランダムな順序データ読み込みます。次にSortedDictionaryDictionary(ジェネリック IEqualityComparer) コンストラクタ渡して並べ替えられた Dictionary作成します。これは、特定のポイント静的になる並べ替えられたディクショナリを構築することが必要である場合有用です。データSortedDictionary から Dictionaryコピーすることにより、検索速度向上します

Imports System
Imports System.Collections.Generic

Public Class Example
    
    Public Shared Sub Main()
 

        ' Create a new sorted dictionary of strings, with string 
        ' keys.
        Dim openWith As New
 SortedDictionary(Of String, String)
        
        ' Add some elements to the sorted dictionary. 
        openWith.Add("txt", "notepad.exe")
        openWith.Add("bmp", "paint.exe")
        openWith.Add("dib", "paint.exe")
        openWith.Add("rtf", "wordpad.exe")
        
        ' Create a Dictionary of strings with string keys, and 
        ' initialize it with the contents of the sorted dictionary.
        Dim copy As New
 Dictionary(Of String, String)(openWith)

        ' List the contents of the copy.
        Console.WriteLine()
        For Each kvp As
 KeyValuePair(Of String, String)
 In copy
            Console.WriteLine("Key = {0}, Value = {1}",
 _
                kvp.Key, kvp.Value)
        Next kvp

    End Sub

End Class

' This code example produces the following output:
'
'Key = bmp, Value = paint.exe
'Key = dib, Value = paint.exe
'Key = rtf, Value = wordpad.exe
'Key = txt, Value = notepad.exe
using System;
using System.Collections.Generic;

public class Example
{
    public static void Main()
    {
        // Create a new sorted dictionary of strings, with string 
        // keys.
        SortedDictionary<string, string>
 openWith = 
            new SortedDictionary<string,
 string>();
        
        // Add some elements to the dictionary. 
        openWith.Add("txt", "notepad.exe");
        openWith.Add("bmp", "paint.exe");
        openWith.Add("dib", "paint.exe");
        openWith.Add("rtf", "wordpad.exe");
        
        // Create a Dictionary of strings with string keys, and 
        // initialize it with the contents of the sorted dictionary.
        Dictionary<string, string> copy
 = 
            new Dictionary<string, string>(openWith);

        // List the contents of the copy.
        Console.WriteLine();
        foreach( KeyValuePair<string, string>
 kvp in copy )
        {
            Console.WriteLine("Key = {0}, Value = {1}", 
               kvp.Key, kvp.Value);
        }
    }
}

/* This code example produces the following output:

Key = bmp, Value = paint.exe
Key = dib, Value = paint.exe
Key = rtf, Value = wordpad.exe
Key = txt, Value = notepad.exe
 */
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Dictionary ジェネリック クラス
Dictionary メンバ
System.Collections.Generic 名前空間
IDictionary
EqualityComparer.Default
IEquatable ジェネリック インターフェイス

Dictionary コンストラクタ (ジェネリック IEqualityComparer)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

空で、既定初期量を備え指定した IEqualityComparer使用する、Dictionary クラス新しインスタンス初期化します。

名前空間: System.Collections.Generic
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    comparer As IEqualityComparer(Of TKey)
 _
)
Dim comparer As IEqualityComparer(Of
 TKey)

Dim instance As New Dictionary(Of
 TKey, TValue)(comparer)
public Dictionary (
    IEqualityComparer<TKey> comparer
)
public:
Dictionary (
    IEqualityComparer<TKey>^ comparer
)
public Dictionary (
    IEqualityComparer<TKey> comparer
)
public function Dictionary (
    comparer : IEqualityComparer<TKey>
)

パラメータ

comparer

キー比較時に使用する IEqualityComparer 実装キーの型の既定の EqualityComparer を使用する場合null 参照 (Visual Basic では Nothing)。

解説解説
使用例使用例

現在のカルチャの大文字小文字区別しない等値比較演算子使って Dictionary作成するコード例次に示します。この例では、小文字キーを含む要素大文字キーを含む要素合わせて 4 つの要素追加します次に既存キーとの違い大文字と小文字違いだけであるキーを含む要素追加試行し結果例外キャッチしエラー メッセージ表示します最後に、ディクショナリの要素表示します

Imports System
Imports System.Collections.Generic

Public Class Example
    
    Public Shared Sub Main()
 

        ' Create a new Dictionary of strings, with string keys 
        ' and a case-insensitive comparer for the current culture.
        Dim openWith As New
 Dictionary(Of String, String)(
 _
            StringComparer.CurrentCultureIgnoreCase)
        
        ' Add some elements to the dictionary. 
        openWith.Add("txt", "notepad.exe")
        openWith.Add("bmp", "paint.exe")
        openWith.Add("DIB", "paint.exe")
        openWith.Add("rtf", "wordpad.exe")

        ' Try to add a fifth element with a key that is the same 
        ' except for case; this would be allowed with the default
        ' comparer.
        Try
            openWith.Add("BMP", "paint.exe")
        Catch ex As ArgumentException
            Console.WriteLine(vbLf & "BMP is already in the
 dictionary.")
        End Try
        
        ' List the contents of the dictionary.
        Console.WriteLine()
        For Each kvp As
 KeyValuePair(Of String, String)
 In openWith
            Console.WriteLine("Key = {0}, Value = {1}",
 _
                kvp.Key, kvp.Value)
        Next kvp

    End Sub

End Class

' This code example produces the following output:
'
'BMP is already in the dictionary.
'
'Key = txt, Value = notepad.exe
'Key = bmp, Value = paint.exe
'Key = DIB, Value = paint.exe
'Key = rtf, Value = wordpad.exe
using System;
using System.Collections.Generic;

public class Example
{
    public static void Main()
    {
        // Create a new Dictionary of strings, with string keys 
        // and a case-insensitive comparer for the current culture.
        Dictionary<string, string> openWith
 = 
                      new Dictionary<string,
 string>( 
                          StringComparer.CurrentCultureIgnoreCase);
        
        // Add some elements to the dictionary.
        openWith.Add("txt", "notepad.exe");
        openWith.Add("bmp", "paint.exe");
        openWith.Add("DIB", "paint.exe");
        openWith.Add("rtf", "wordpad.exe");

        // Try to add a fifth element with a key that is the same 
        // except for case; this would be allowed with the default
        // comparer.
        try
        {
            openWith.Add("BMP", "paint.exe");
        }
        catch (ArgumentException)
        {
            Console.WriteLine("\nBMP is already in the dictionary.");
        }
        
        // List the contents of the sorted dictionary.
        Console.WriteLine();
        foreach( KeyValuePair<string, string>
 kvp in openWith )
        {
            Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, 
                kvp.Value);
        }
    }
}

/* This code example produces the following output:

BMP is already in the dictionary.

Key = txt, Value = notepad.exe
Key = bmp, Value = paint.exe
Key = DIB, Value = paint.exe
Key = rtf, Value = wordpad.exe
 */
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Dictionary ジェネリック クラス
Dictionary メンバ
System.Collections.Generic 名前空間
IEqualityComparer
EqualityComparer.Default
IEquatable ジェネリック インターフェイス

Dictionary コンストラクタ (ジェネリック IDictionary, ジェネリック IEqualityComparer)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

指定した IDictionary から要素コピーして格納し指定した IEqualityComparer使用するDictionary クラス新しインスタンス初期化します。

名前空間: System.Collections.Generic
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    dictionary As IDictionary(Of TKey, TValue),
 _
    comparer As IEqualityComparer(Of TKey)
 _
)
Dim dictionary As IDictionary(Of
 TKey, TValue)
Dim comparer As IEqualityComparer(Of
 TKey)

Dim instance As New Dictionary(Of
 TKey, TValue)(dictionary, comparer)
public Dictionary (
    IDictionary<TKey,TValue> dictionary,
    IEqualityComparer<TKey> comparer
)
public:
Dictionary (
    IDictionary<TKey, TValue>^ dictionary, 
    IEqualityComparer<TKey>^ comparer
)
public Dictionary (
    IDictionary<TKey,TValue> dictionary, 
    IEqualityComparer<TKey> comparer
)
public function Dictionary (
    dictionary : IDictionary<TKey,TValue>, 
    comparer : IEqualityComparer<TKey>
)

パラメータ

dictionary

新しい Dictionary に要素コピーされた IDictionary。

comparer

キー比較時に使用する IEqualityComparer 実装キーの型の既定の EqualityComparer を使用する場合null 参照 (Visual Basic では Nothing)。

例外例外
例外種類条件

ArgumentNullException

dictionarynull 参照 (Visual Basic では Nothing) です。

ArgumentException

dictionary に、1 つ上の重複するキー格納されています。

解説解説

このコンストラクタを、StringComparer クラスによって提供される大文字と小文字区別しない文字列比較演算子使用して大文字と小文字区別しない文字列キーを持つディクショナリを作成します

Dictionary 内のすべてのキーは、指定した比較演算子に従って一意である必要があります同様に、元の dictionary 内のすべてのキーも、指定した比較演算子に従って一意である必要があります

メモメモ

たとえば、comparerStringComparer クラスによって提供される大文字と小文字区別しない文字列比較演算子1 つであり、dictionary大文字と小文字区別しない比較演算子キー使用しない場合キー重複する可能性あります

新しDictionary初期量は、dictionary 内のすべての要素格納できるサイズです。

Dictionary は、キーが同じであるかどうか確認するための等値比較実装を必要としますcomparernull 参照 (Visual Basic では Nothing) の場合、このコンストラクタは、既定ジェネリック等値比較演算子である EqualityComparer.Default を使用します。型 TKey が System.IEquatable ジェネリック インターフェイス実装している場合は、既定等値比較演算子その実装が使用されます。

このコンストラクタは O(n) 操作です (ndictionary 内の要素数)。

使用例使用例

Dictionary(ジェネリック IDictionary,ジェネリック IEqualityComparer) コンストラクタ使用し大文字小文字区別しない並べ替えられた別のディクショナリの内容によって Dictionary初期化する方法次のコード例示します。このコード例では、大文字小文字区別しない比較演算子使って SortedDictionary を作成し、このディクショナリにランダムな順序データ読み込みます。次に大文字小文字区別しない等値比較演算子と共に SortedDictionaryDictionary(ジェネリック IDictionary,ジェネリック IEqualityComparer) コンストラクタ渡して並べ替えられた Dictionary作成します。これは、特定のポイント静的になる並べ替えられたディクショナリを構築することが必要である場合有用です。データSortedDictionary から Dictionaryコピーすることにより、検索速度向上します

メモメモ

この例のように、大文字と小文字区別しない比較演算子使用する新しいディクショナリを作成し、それに大文字と小文字区別する比較演算子使用するディクショナリのエントリ読み込む場合入力ディクショナリに大文字と小文字が違うだけのキーがあると例外発生します

Imports System
Imports System.Collections.Generic

Public Class Example
    
    Public Shared Sub Main()
 

        ' Create a new sorted dictionary of strings, with string 
        ' keys and a case-insensitive comparer.
        Dim openWith As New
 SortedDictionary(Of String, String)(
 _
            StringComparer.CurrentCultureIgnoreCase)
        
        ' Add some elements to the sorted dictionary. 
        openWith.Add("txt", "notepad.exe")
        openWith.Add("Bmp", "paint.exe")
        openWith.Add("DIB", "paint.exe")
        openWith.Add("rtf", "wordpad.exe")
        
        ' Create a Dictionary of strings with string keys and a 
        ' case-insensitive equality comparer, and initialize it
        ' with the contents of the sorted dictionary.
        Dim copy As New
 Dictionary(Of String, String)(openWith,
 _
            StringComparer.CurrentCultureIgnoreCase)

        ' List the contents of the copy.
        Console.WriteLine()
        For Each kvp As
 KeyValuePair(Of String, String)
 In copy
            Console.WriteLine("Key = {0}, Value = {1}",
 _
                kvp.Key, kvp.Value)
        Next kvp

    End Sub

End Class

' This code example produces the following output:
'
'Key = Bmp, Value = paint.exe
'Key = DIB, Value = paint.exe
'Key = rtf, Value = wordpad.exe
'Key = txt, Value = notepad.exe
using System;
using System.Collections.Generic;

public class Example
{
    public static void Main()
    {
        // Create a new sorted dictionary of strings, with string 
        // keys and a case-insensitive comparer.
        SortedDictionary<string, string>
 openWith = 
                new SortedDictionary<string,
 string>(
                    StringComparer.CurrentCultureIgnoreCase);
        
        // Add some elements to the dictionary. 
        openWith.Add("txt", "notepad.exe");
        openWith.Add("Bmp", "paint.exe");
        openWith.Add("DIB", "paint.exe");
        openWith.Add("rtf", "wordpad.exe");
        
        // Create a Dictionary of strings with string keys and a
        // case-insensitive equality comparer, and initialize it
        // with the contents of the sorted dictionary.
        Dictionary<string, string> copy
 = 
                new Dictionary<string, string>(openWith,
 
                    StringComparer.CurrentCultureIgnoreCase);

        // List the contents of the copy.
        Console.WriteLine();
        foreach( KeyValuePair<string, string>
 kvp in copy )
        {
            Console.WriteLine("Key = {0}, Value = {1}", 
               kvp.Key, kvp.Value);
        }
    }
}

/* This code example produces the following output:

Key = Bmp, Value = paint.exe
Key = DIB, Value = paint.exe
Key = rtf, Value = wordpad.exe
Key = txt, Value = notepad.exe
 */
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Dictionary ジェネリック クラス
Dictionary メンバ
System.Collections.Generic 名前空間
IDictionary
IEqualityComparer
EqualityComparer.Default
IEquatable ジェネリック インターフェイス

Dictionary コンストラクタ (Int32, ジェネリック IEqualityComparer)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

空で、指定した初期量を備え指定した IEqualityComparer使用するDictionary クラス新しインスタンス初期化します。

名前空間: System.Collections.Generic
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    capacity As Integer, _
    comparer As IEqualityComparer(Of TKey)
 _
)
Dim capacity As Integer
Dim comparer As IEqualityComparer(Of
 TKey)

Dim instance As New Dictionary(Of
 TKey, TValue)(capacity, comparer)
public Dictionary (
    int capacity,
    IEqualityComparer<TKey> comparer
)
public:
Dictionary (
    int capacity, 
    IEqualityComparer<TKey>^ comparer
)
public Dictionary (
    int capacity, 
    IEqualityComparer<TKey> comparer
)
public function Dictionary (
    capacity : int, 
    comparer : IEqualityComparer<TKey>
)

パラメータ

capacity

Dictionary が格納できる要素数の初期値

comparer

キー比較時に使用する IEqualityComparer 実装キーの型の既定の EqualityComparer を使用する場合null 参照 (Visual Basic では Nothing)。

例外例外
例外種類条件

ArgumentOutOfRangeException

capacity が 0 未満です。

解説解説
使用例使用例

初期量 5 で、現在のカルチャの大文字小文字区別しない等値比較演算子使って Dictionary作成するコード例次に示します。この例では、小文字キーを含む要素大文字キーを含む要素合わせて 4 つの要素追加します次に既存キーとの違い大文字と小文字違いだけであるキーを含む要素追加試行し結果例外キャッチしエラー メッセージ表示します最後に、ディクショナリの要素表示します

Imports System
Imports System.Collections.Generic

Public Class Example
    
    Public Shared Sub Main()
 

        ' Create a new Dictionary of strings, with string keys, an
        ' initial capacity of 5, and a case-insensitive equality
        ' comparer.
        Dim openWith As New
 Dictionary(Of String, String)(5,
 _
            StringComparer.CurrentCultureIgnoreCase)
        
        ' Add 4 elements to the dictionary. 
        openWith.Add("txt", "notepad.exe")
        openWith.Add("bmp", "paint.exe")
        openWith.Add("DIB", "paint.exe")
        openWith.Add("rtf", "wordpad.exe")

        ' Try to add a fifth element with a key that is the same 
        ' except for case; this would be allowed with the default
        ' comparer.
        Try
            openWith.Add("BMP", "paint.exe")
        Catch ex As ArgumentException
            Console.WriteLine(vbLf & "BMP is already in the
 dictionary.")
        End Try
        
        ' List the contents of the dictionary.
        Console.WriteLine()
        For Each kvp As
 KeyValuePair(Of String, String)
 In openWith
            Console.WriteLine("Key = {0}, Value = {1}",
 _
                kvp.Key, kvp.Value)
        Next kvp

    End Sub

End Class

' This code example produces the following output:
'
'BMP is already in the dictionary.
'
'Key = txt, Value = notepad.exe
'Key = bmp, Value = paint.exe
'Key = DIB, Value = paint.exe
'Key = rtf, Value = wordpad.exe
using System;
using System.Collections.Generic;

public class Example
{
    public static void Main()
    {
        // Create a new dictionary of strings, with string keys, an
        // initial capacity of 5, and a case-insensitive equality 
        // comparer.
        Dictionary<string, string> openWith
 = 
                      new Dictionary<string,
 string>(5, 
                          StringComparer.CurrentCultureIgnoreCase);
        
        // Add 4 elements to the dictionary. 
        openWith.Add("txt", "notepad.exe");
        openWith.Add("bmp", "paint.exe");
        openWith.Add("DIB", "paint.exe");
        openWith.Add("rtf", "wordpad.exe");

        // Try to add a fifth element with a key that is the same 
        // except for case; this would be allowed with the default
        // comparer.
        try
        {
            openWith.Add("BMP", "paint.exe");
        }
        catch (ArgumentException)
        {
            Console.WriteLine("\nBMP is already in the dictionary.");
        }
        
        // List the contents of the dictionary.
        Console.WriteLine();
        foreach( KeyValuePair<string, string>
 kvp in openWith )
        {
            Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, 
                kvp.Value);
        }
    }
}

/* This code example produces the following output:

BMP is already in the dictionary.

Key = txt, Value = notepad.exe
Key = bmp, Value = paint.exe
Key = DIB, Value = paint.exe
Key = rtf, Value = wordpad.exe
 */
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Dictionary ジェネリック クラス
Dictionary メンバ
System.Collections.Generic 名前空間
IEqualityComparer
EqualityComparer.Default
IEquatable ジェネリック インターフェイス

Dictionary コンストラクタ (Int32)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

空で、指定した初期量を備えキーの型の既定等値比較演算子使用するDictionary クラス新しインスタンス初期化します。

名前空間: System.Collections.Generic
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

例外例外
例外種類条件

ArgumentOutOfRangeException

capacity が 0 未満です。

解説解説
使用例使用例

ディクショナリを初期量 4 で作成し4 つエントリ設定するコード例次に示します

Imports System
Imports System.Collections.Generic

Public Class Example
    
    Public Shared Sub Main()
 

        ' Create a new dictionary of strings, with string keys and
        ' an initial capacity of 4.
        Dim openWith As New
 Dictionary(Of String, String)(4)
        
        ' Add 4 elements to the dictionary. 
        openWith.Add("txt", "notepad.exe")
        openWith.Add("bmp", "paint.exe")
        openWith.Add("dib", "paint.exe")
        openWith.Add("rtf", "wordpad.exe")
        
        ' List the contents of the dictionary.
        Console.WriteLine()
        For Each kvp As
 KeyValuePair(Of String, String)
 In openWith
            Console.WriteLine("Key = {0}, Value = {1}",
 _
                kvp.Key, kvp.Value)
        Next kvp

    End Sub

End Class

' This code example produces the following output:
'
'Key = txt, Value = notepad.exe
'Key = bmp, Value = paint.exe
'Key = dib, Value = paint.exe
'Key = rtf, Value = wordpad.exe
using System;
using System.Collections.Generic;

public class Example
{
    public static void Main()
    {
        // Create a new dictionary of strings, with string keys and
        // an initial capacity of 4.
        Dictionary<string, string> openWith
 = 
                               new Dictionary<string,
 string>(4);
        
        // Add 4 elements to the dictionary. 
        openWith.Add("txt", "notepad.exe");
        openWith.Add("bmp", "paint.exe");
        openWith.Add("dib", "paint.exe");
        openWith.Add("rtf", "wordpad.exe");
        
        // List the contents of the dictionary.
        Console.WriteLine();
        foreach( KeyValuePair<string, string>
 kvp in openWith )
        {
            Console.WriteLine("Key = {0}, Value = {1}", 
               kvp.Key, kvp.Value);
        }
    }
}

/* This code example produces the following output:

Key = txt, Value = notepad.exe
Key = bmp, Value = paint.exe
Key = dib, Value = paint.exe
Key = rtf, Value = wordpad.exe
 */
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Dictionary ジェネリック クラス
Dictionary メンバ
System.Collections.Generic 名前空間
EqualityComparer.Default
IEquatable ジェネリック インターフェイス

Dictionary ジェネリック クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

キーと値のコレクション表します

名前空間: System.Collections.Generic
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ComVisibleAttribute(False)> _
Public Class Dictionary(Of
 TKey, TValue)
    Implements IDictionary(Of TKey, TValue),
 ICollection(Of KeyValuePair(Of TKey, TValue)),
 _
    IEnumerable(Of KeyValuePair(Of TKey, TValue)),
 IDictionary, ICollection, _
    IEnumerable, ISerializable, IDeserializationCallback
Dim instance As Dictionary(Of
 TKey, TValue)
[SerializableAttribute] 
[ComVisibleAttribute(false)] 
public class Dictionary<TKey,TValue>
 : IDictionary<TKey,TValue>, ICollection<KeyValuePair<TKey,TValue>>,
 
    IEnumerable<KeyValuePair<TKey,TValue>>, IDictionary, ICollection,
 IEnumerable, 
    ISerializable, IDeserializationCallback
[SerializableAttribute] 
[ComVisibleAttribute(false)] 
generic<typename TKey, typename TValue>
public ref class Dictionary : IDictionary<TKey,
 TValue>, ICollection<KeyValuePair<TKey, TValue>>, 
    IEnumerable<KeyValuePair<TKey, TValue>>, IDictionary, ICollection,
 IEnumerable, 
    ISerializable, IDeserializationCallback
J# では、ジェネリックな型およびメソッド使用できますが、新規に宣言することはできません。
JScript では、ジェネリックな型およびメソッド使用できません。

型パラメータ

TKey

ディクショナリ内のキーの型。

TValue

ディクショナリ内の値の型。

解説解説

Dictionary ジェネリック クラスにより、キーセットを値のセット対応付けることができます。ディクショナリに追加されるエントリは、値とその値に関連付けられたキー構成されます。Dictionary クラスハッシュ テーブルとして実装されているため、キー使用した値の取得は非常に高速で、O(1)近くなります

メモメモ

取得速度は、TKey指定されている型のハッシュ アルゴリズム品質によって異なります

オブジェクトDictionaryキーとして使用されている場合、そのオブジェクトに対してハッシュ値影響するような変更行わないくださいDictionary 内のすべてのキーは、ディクショナリの等値比較演算子に従って一意である必要がありますキーnull 参照 (Visual Basic では Nothing) にすることはできませんが、値の型 TValue参照型である場合、値を null にすることはできます

Dictionary は、キーが同じであるかどうか確認するための等値比較実装を必要としますcomparer パラメータ受け付けコンストラクタ使用して、IEqualityComparer ジェネリック インターフェイス実装指定できます実装指定しない場合は、既定ジェネリック等値比較演算子である EqualityComparer.Default が使用されます。TKey が System.IEquatable ジェネリック インターフェイス実装している場合は、既定等値比較演算子その実装が使用されます。

メモメモ

たとえば、StringComparer クラスによって提供される大文字と小文字区別しない文字列比較演算子使用して大文字と小文字区別しない文字列キーを持つディクショナリを作成できます

Dictionary容量は、Dictionary保持できる要素数になります。この実装では、Dictionary既定初期量は 3 ですが、この既定値将来.NET Frameworkバージョン変更される可能性ありますDictionary要素追加すると、必要に応じて内部配列の再割り当てによって容量自動的に増加します。

列挙処理のために、ディクショナリ内のアイテムは、値とそのキーを表す KeyValuePair 構造体として処理されます。アイテム返される順序未定義です。

C# 言語foreach ステートメント (C++ の場合for eachVisual Basic の場合For Each) は、コレクション内の各要素の型を必要としますDictionaryキーと値のコレクションであるため、要素の型は、キーの型や値の型にはなりません。代わりに要素の型は、キーの型および値の型の KeyValuePairなります次に例を示します

foreach (KeyValuePair<int, string>
 kvp in myDictionary) {...}
for each (KeyValuePair<int, String^>
 kvp in myDictionary) {...}
For Each kvp As KeyValuePair(Of
 Integer, String) In myDictionary
    ...
Next kvp

foreach ステートメントは、列挙子のラッパーです。これは、コレクションからの読み取りだけを許可しコレクションへの書き込みはできません。

使用例使用例

文字列キーを含む文字列の空の Dictionary作成しAdd メソッド使用していくつかの要素追加するコード例次に示します。この例では、重複するキー追加しようとすると、Add メソッドが ArgumentException をスローすることを示します

この例では、Item プロパティ (C# ではインデクサ) を使用して値を取得し要求されキー存在しないときに KeyNotFoundException がスローされる例を示し、またキー関連付けられた値を置き換えることができること示します

この例では、プログラムがディクショナリにないキー値を頻繁に試行する必要がある場合に、より効率的に値を取得する方法として TryGetValue メソッド使用する方法、および ContainsKey メソッド使用してAdd メソッド呼び出す前にキー存在するかどうかテストする方法示します

この例では、ディクショナリのキーと値を列挙する方法、および Keys プロパティValues プロパティ使用してキーと値のみを列挙する方法示します

最後にRemove メソッド使用例示します

Imports System
Imports System.Collections.Generic

Public Class Example
    
    Public Shared Sub Main()
 

        ' Create a new dictionary of strings, with string keys.
        '
        Dim openWith As New
 Dictionary(Of String, String)
        
        ' Add some elements to the dictionary. 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 dictionary.
        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"

        ' The default Item property throws an exception if the requested
        ' key is not in the dictionary.
        Try
            Console.WriteLine("For key = ""tif"",
 value = {0}.", _
                openWith("tif"))
        Catch 
            Console.WriteLine("Key = ""tif""
 is not found.")
        End Try

        ' When a program often has to try keys that turn out not to
        ' be in the dictionary, TryGetValue can be a more efficient
 
        ' way to retrieve values.
        Dim value As String
 = ""
        If openWith.TryGetValue("tif",
 value) Then
            Console.WriteLine("For key = ""tif"",
 value = {0}.", value)
        Else
            Console.WriteLine("Key = ""tif""
 is not found.")
        End If

        ' 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 dictionary elements,
        ' the elements are retrieved as KeyValuePair objects.
        Console.WriteLine()
        For Each kvp As
 KeyValuePair(Of String, String)
 In openWith
            Console.WriteLine("Key = {0}, Value = {1}",
 _
                kvp.Key, kvp.Value)
        Next kvp

        ' To get the values alone, use the Values property.
        Dim valueColl As _
            Dictionary(Of String, String).ValueCollection
 = _
            openWith.Values
        
        ' The elements of the ValueCollection are strongly typed
        ' with the type that was specified for dictionary 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 _
            Dictionary(Of String, String).KeyCollection
 = _
            openWith.Keys
        
        ' The elements of the KeyCollection are strongly typed
        ' with the type that was specified for dictionary 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 Class

' 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.
'Key = "tif" is not found.
'Key = "tif" is not found.
'Value added for key = "ht": hypertrm.exe
'
'Key = txt, Value = notepad.exe
'Key = bmp, Value = paint.exe
'Key = dib, Value = paint.exe
'Key = rtf, Value = winword.exe
'Key = doc, Value = winword.exe
'Key = ht, Value = hypertrm.exe
'
'Value = notepad.exe
'Value = paint.exe
'Value = paint.exe
'Value = winword.exe
'Value = winword.exe
'Value = hypertrm.exe
'
'Key = txt
'Key = bmp
'Key = dib
'Key = rtf
'Key = doc
'Key = ht
'
'Remove("doc")
'Key "doc" is not found.
' 
using System;
using System.Collections.Generic;

public class Example
{
    public static void Main()
    {
        // Create a new dictionary of strings, with string keys.
        //
        Dictionary<string, string> openWith
 = 
            new Dictionary<string, string>();

        // Add some elements to the dictionary. 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 dictionary.
        try
        {
            openWith.Add("txt", "winword.exe");
        }
        catch (ArgumentException)
        {
            Console.WriteLine("An element with Key = \"txt\" already
 exists.");
        }

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

        // The indexer 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 indexer for that key
        // adds a new key/value pair.
        openWith["doc"] = "winword.exe";

        // The indexer throws an exception if the requested key is
        // not in the dictionary.
        try
        {
            Console.WriteLine("For key = \"tif\", value = {0}.",
 
                openWith["tif"]);
        }
        catch (KeyNotFoundException)
        {
            Console.WriteLine("Key = \"tif\" is not found.");
        }

        // When a program often has to try keys that turn out not to
        // be in the dictionary, TryGetValue can be a more efficient
 
        // way to retrieve values.
        string value = "";
        if (openWith.TryGetValue("tif", out value))
        {
            Console.WriteLine("For key = \"tif\", value = {0}.",
 value);
        }
        else
        {
            Console.WriteLine("Key = \"tif\" is not found.");
        }

        // 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 dictionary elements,
        // the elements are retrieved as KeyValuePair objects.
        Console.WriteLine();
        foreach( KeyValuePair<string, string>
 kvp in openWith )
        {
            Console.WriteLine("Key = {0}, Value = {1}", 
                kvp.Key, kvp.Value);
        }

        // To get the values alone, use the Values property.
        Dictionary<string, string>.ValueCollection
 valueColl =
            openWith.Values;

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

        // To get the keys alone, use the Keys property.
        Dictionary<string, string>.KeyCollection
 keyColl =
            openWith.Keys;

        // The elements of the KeyCollection are strongly typed
        // with the type that was specified for dictionary 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.
Key = "tif" is not found.
Key = "tif" is not found.
Value added for key = "ht": hypertrm.exe

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

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

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

Remove("doc")
Key "doc" is not found.
 */
継承階層継承階層
System.Object
  System.Collections.Generic.Dictionary
スレッド セーフスレッド セーフ

この型の public static (Visual Basic では Shared) メンバは、スレッド セーフです。すべてのインスタンス メンバスレッド セーフになるかどうか保証されていません。

コレクション変更されない限りDictionary では、複数読み込み操作同時に発生して問題ありません。ただし、コレクション列挙処理は、本質的にスレッド セーフな処理ではありません。まれに書き込みアクセスによって列挙処理で競合発生する場合列挙処理が完了するまでコレクションロックする必要がありますコレクション対し複数スレッドアクセスして読み取り書き込みを行うことができるようにするには、独自に同期化実装する必要があります

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Dictionary メンバ
System.Collections.Generic 名前空間
IDictionary
SortedList
KeyValuePair
IEqualityComparer

Dictionary プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Values Dictionary 内の値を格納しているコレクション取得します
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.IDictionary.Values IDictionary 内の値を格納している ICollection取得します
参照参照

関連項目

Dictionary ジェネリック クラス
System.Collections.Generic 名前空間
IDictionary
SortedList
KeyValuePair
IEqualityComparer

Dictionary メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Add 指定したキーと値をディクショナリに追加します
パブリック メソッド Clear Dictionary からすべてのキーと値を削除します
パブリック メソッド ContainsKey 指定したキーDictionary格納されているかどうか判断します
パブリック メソッド ContainsValue Dictionary特定の値格納されているかどうか判断します
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド GetEnumerator Dictionary反復処理する列挙子を返します
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetObjectData System.Runtime.Serialization.ISerializable インターフェイス実装し、Dictionary インスタンスシリアル化するために必要なデータ返します
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド OnDeserialization System.Runtime.Serialization.ISerializable インターフェイス実装し、逆シリアル化完了したときに逆シリアル化イベント発生させます
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド Remove 指定したキーを持つ値を Dictionary から削除します
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
パブリック メソッド TryGetValue 指定したキー関連付けられている値を取得します
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Add 指定した値を、指定したキーと共に ICollection に追加します
インターフェイスの明示的な実装 System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Contains ICollection特定のキーと値が格納されているかどうか判断します
インターフェイスの明示的な実装 System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.CopyTo 指定した配列インデックス開始位置として、KeyValuePair 型の配列ICollection要素コピーします
インターフェイスの明示的な実装 System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Remove ディクショナリからキーと値を削除します
インターフェイスの明示的な実装 System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>>.GetEnumerator コレクション反復処理する列挙子を返します
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo 指定した配列インデックス開始位置として、配列ICollection要素コピーします
インターフェイスの明示的な実装 System.Collections.IDictionary.Add 指定したキーと値をディクショナリに追加します
インターフェイスの明示的な実装 System.Collections.IDictionary.Contains 指定したキー要素が IDictionary に格納されているかどうか確認します
インターフェイスの明示的な実装 System.Collections.IDictionary.GetEnumerator IDictionary の IDictionaryEnumerator を返します
インターフェイスの明示的な実装 System.Collections.IDictionary.Remove 指定したキー持つ要素IDictionary から削除します
インターフェイスの明示的な実装 System.Collections.IEnumerable.GetEnumerator コレクション反復処理する列挙子を返します
参照参照

関連項目

Dictionary ジェネリック クラス
System.Collections.Generic 名前空間
IDictionary
SortedList
KeyValuePair
IEqualityComparer

Dictionary メンバ

キーと値のコレクション表します

Dictionary ジェネリック型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
プロテクト コンストラクタプロテクト コンストラクタ
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Values Dictionary 内の値を格納しているコレクション取得します
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Add 指定したキーと値をディクショナリに追加します
パブリック メソッド Clear Dictionary からすべてのキーと値を削除します
パブリック メソッド ContainsKey 指定したキーDictionary格納されているかどうか判断します
パブリック メソッド ContainsValue Dictionary特定の値格納されているかどうか判断します
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド GetEnumerator Dictionary反復処理する列挙子を返します
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetObjectData System.Runtime.Serialization.ISerializable インターフェイス実装し、Dictionary インスタンスシリアル化するために必要なデータ返します
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド OnDeserialization System.Runtime.Serialization.ISerializable インターフェイス実装し、逆シリアル化完了したときに逆シリアル化イベント発生させます
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド Remove 指定したキーを持つ値を Dictionary から削除します
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
パブリック メソッド TryGetValue 指定したキー関連付けられている値を取得します
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Add 指定した値を、指定したキーと共に ICollection に追加します
インターフェイスの明示的な実装 System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Contains ICollection特定のキーと値が格納されているかどうか判断します
インターフェイスの明示的な実装 System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.CopyTo 指定した配列インデックス開始位置として、KeyValuePair 型の配列ICollection要素コピーします
インターフェイスの明示的な実装 System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Remove ディクショナリからキーと値を削除します
インターフェイスの明示的な実装 System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>>.GetEnumerator コレクション反復処理する列挙子を返します
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo 指定した配列インデックス開始位置として、配列ICollection要素コピーします
インターフェイスの明示的な実装 System.Collections.IDictionary.Add 指定したキーと値をディクショナリに追加します
インターフェイスの明示的な実装 System.Collections.IDictionary.Contains 指定したキー要素が IDictionary に格納されているかどうか確認します
インターフェイスの明示的な実装 System.Collections.IDictionary.GetEnumerator IDictionary の IDictionaryEnumerator を返します
インターフェイスの明示的な実装 System.Collections.IDictionary.Remove 指定したキー持つ要素IDictionary から削除します
インターフェイスの明示的な実装 System.Collections.IEnumerable.GetEnumerator コレクション反復処理する列挙子を返します
インターフェイスの明示的な実装 System.Collections.IDictionary.Values IDictionary 内の値を格納している ICollection取得します
参照参照

関連項目

Dictionary ジェネリック クラス
System.Collections.Generic 名前空間
IDictionary
SortedList
KeyValuePair
IEqualityComparer


このページでは「.NET Framework クラス ライブラリ リファレンス」からdictionary!を検索した結果を表示しています。
Weblioに収録されているすべての辞書からdictionary!を検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からdictionary! を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「dictionary!」の関連用語

dictionary!のお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



dictionary!のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS