OrderedDictionary 建構函式

定義

初始化 OrderedDictionary 類別的新執行個體。

多載

OrderedDictionary()

初始化 OrderedDictionary 類別的新執行個體。

OrderedDictionary(IEqualityComparer)

使用指定之比較子來初始化 OrderedDictionary 類別的新執行個體。

OrderedDictionary(Int32)

使用指定之初始容量來初始化 OrderedDictionary 類別的新執行個體。

OrderedDictionary(Int32, IEqualityComparer)

使用指定的初始容量和比較子,初始化 OrderedDictionary 類別的新執行個體。

OrderedDictionary(SerializationInfo, StreamingContext)
已淘汰.

使用指定的 OrderedDictionarySerializationInfo 物件,初始化 StreamingContext 類別的執行個體,這個執行個體是可序列化的。

OrderedDictionary()

來源:
OrderedDictionary.cs
來源:
OrderedDictionary.cs
來源:
OrderedDictionary.cs

初始化 OrderedDictionary 類別的新執行個體。

public:
 OrderedDictionary();
public OrderedDictionary ();
Public Sub New ()

範例

下列程式代碼範例示範集合的 OrderedDictionary 建立和擴展。 此程式代碼是可在 上 OrderedDictionary檢視之較大程式碼範例的一部分。

// Creates and initializes a OrderedDictionary.
OrderedDictionary^ myOrderedDictionary = gcnew OrderedDictionary();
myOrderedDictionary->Add("testKey1", "testValue1");
myOrderedDictionary->Add("testKey2", "testValue2");
myOrderedDictionary->Add("keyToDelete", "valueToDelete");
myOrderedDictionary->Add("testKey3", "testValue3");

ICollection^ keyCollection = myOrderedDictionary->Keys;
ICollection^ valueCollection = myOrderedDictionary->Values;

// Display the contents using the key and value collections
DisplayContents(keyCollection, valueCollection, myOrderedDictionary->Count);
// Creates and initializes a OrderedDictionary.
OrderedDictionary myOrderedDictionary = new OrderedDictionary();
myOrderedDictionary.Add("testKey1", "testValue1");
myOrderedDictionary.Add("testKey2", "testValue2");
myOrderedDictionary.Add("keyToDelete", "valueToDelete");
myOrderedDictionary.Add("testKey3", "testValue3");

ICollection keyCollection = myOrderedDictionary.Keys;
ICollection valueCollection = myOrderedDictionary.Values;

// Display the contents using the key and value collections
DisplayContents(keyCollection, valueCollection, myOrderedDictionary.Count);
' Creates and initializes a OrderedDictionary.
Dim myOrderedDictionary As New OrderedDictionary()
myOrderedDictionary.Add("testKey1", "testValue1")
myOrderedDictionary.Add("testKey2", "testValue2")
myOrderedDictionary.Add("keyToDelete", "valueToDelete")
myOrderedDictionary.Add("testKey3", "testValue3")

Dim keyCollection As ICollection = myOrderedDictionary.Keys
Dim valueCollection As ICollection = myOrderedDictionary.Values

' Display the contents Imports the key and value collections
DisplayContents( _
    keyCollection, valueCollection, myOrderedDictionary.Count)

備註

比較子會判斷兩個索引鍵是否相等。 集合中的每個索引鍵都必須是唯一 OrderedDictionary 的。 默認比較子是 索引鍵的 實作 Object.Equals

適用於

OrderedDictionary(IEqualityComparer)

來源:
OrderedDictionary.cs
來源:
OrderedDictionary.cs
來源:
OrderedDictionary.cs

使用指定之比較子來初始化 OrderedDictionary 類別的新執行個體。

public:
 OrderedDictionary(System::Collections::IEqualityComparer ^ comparer);
public OrderedDictionary (System.Collections.IEqualityComparer comparer);
public OrderedDictionary (System.Collections.IEqualityComparer? comparer);
new System.Collections.Specialized.OrderedDictionary : System.Collections.IEqualityComparer -> System.Collections.Specialized.OrderedDictionary
Public Sub New (comparer As IEqualityComparer)

參數

comparer
IEqualityComparer

IComparer,可用來判斷兩個索引鍵是否相等。

-或-

表示使用預設比較子的 null,預設比較子是每個索引鍵的 Equals(Object) 實作。

備註

比較子會判斷兩個索引鍵是否相等。 集合中的每個索引鍵都必須是唯一 OrderedDictionary 的。 默認比較子是 索引鍵的 實作 Object.Equals

自定義比較子會啟用這類案例,例如使用不區分大小寫的字串進行查閱。

適用於

OrderedDictionary(Int32)

來源:
OrderedDictionary.cs
來源:
OrderedDictionary.cs
來源:
OrderedDictionary.cs

使用指定之初始容量來初始化 OrderedDictionary 類別的新執行個體。

public:
 OrderedDictionary(int capacity);
public OrderedDictionary (int capacity);
new System.Collections.Specialized.OrderedDictionary : int -> System.Collections.Specialized.OrderedDictionary
Public Sub New (capacity As Integer)

參數

capacity
Int32

OrderedDictionary 集合可以包含之元素的初始數目。

備註

比較子會判斷兩個索引鍵是否相等。 集合中的每個索引鍵都必須是唯一 OrderedDictionary 的。 默認比較子是 索引鍵的 實作 Object.Equals

適用於

OrderedDictionary(Int32, IEqualityComparer)

來源:
OrderedDictionary.cs
來源:
OrderedDictionary.cs
來源:
OrderedDictionary.cs

使用指定的初始容量和比較子,初始化 OrderedDictionary 類別的新執行個體。

public:
 OrderedDictionary(int capacity, System::Collections::IEqualityComparer ^ comparer);
public OrderedDictionary (int capacity, System.Collections.IEqualityComparer comparer);
public OrderedDictionary (int capacity, System.Collections.IEqualityComparer? comparer);
new System.Collections.Specialized.OrderedDictionary : int * System.Collections.IEqualityComparer -> System.Collections.Specialized.OrderedDictionary
Public Sub New (capacity As Integer, comparer As IEqualityComparer)

參數

capacity
Int32

OrderedDictionary 集合可以包含之元素的初始數目。

comparer
IEqualityComparer

IComparer,可用來判斷兩個索引鍵是否相等。

-或-

表示使用預設比較子的 null,預設比較子是每個索引鍵的 Equals(Object) 實作。

備註

比較子會判斷兩個索引鍵是否相等。 集合中的每個索引鍵都必須是唯一 OrderedDictionary 的。 默認比較子是 索引鍵的 實作 Object.Equals

自定義比較子會啟用這類案例,例如使用不區分大小寫的字串進行查閱。

適用於

OrderedDictionary(SerializationInfo, StreamingContext)

來源:
OrderedDictionary.cs
來源:
OrderedDictionary.cs
來源:
OrderedDictionary.cs

警告

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

使用指定的 OrderedDictionarySerializationInfo 物件,初始化 StreamingContext 類別的執行個體,這個執行個體是可序列化的。

protected:
 OrderedDictionary(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected OrderedDictionary (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected OrderedDictionary (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Collections.Specialized.OrderedDictionary : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Collections.Specialized.OrderedDictionary
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Collections.Specialized.OrderedDictionary : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Collections.Specialized.OrderedDictionary
Protected Sub New (info As SerializationInfo, context As StreamingContext)

參數

info
SerializationInfo

SerializationInfo 物件,包含序列化 OrderedDictionary 集合所需的資訊。

context
StreamingContext

StreamingContext 物件,包含 OrderedDictionary 所關聯之序列化資料流的來源及目的地。

屬性

備註

比較子會判斷兩個索引鍵是否相等。 集合中的每個索引鍵都必須是唯一 OrderedDictionary 的。 默認比較子是 索引鍵的 實作 Object.Equals

適用於