語言

OrderedDictionary 建構函式

定義

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

多載

名稱 Description
OrderedDictionary()

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

OrderedDictionary(IEqualityComparer)

使用指定的比較器初始化該 OrderedDictionary 類別的新實例。

OrderedDictionary(Int32)

使用指定的初始容量初始化該 OrderedDictionary 類別的新實例。

OrderedDictionary(Int32, IEqualityComparer)

使用指定的初始容量與比較器初始化該類別的新實例 OrderedDictionary 。

OrderedDictionary(SerializationInfo, StreamingContext)
已淘汰.

初始化一個可使用指定 OrderedDictionary 和 SerializationInfo 物件序列化的類別新實例StreamingContext。

OrderedDictionary()

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

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

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

範例

以下程式碼範例展示了集合的 OrderedDictionary 建立與建立。 此程式碼是更大程式碼範例的一部分,可於 OrderedDictionary。

// 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.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.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.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
來源:
OrderedDictionary.cs
來源:
OrderedDictionary.cs

警告

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

初始化一個可使用指定 OrderedDictionary 和 SerializationInfo 物件序列化的類別新實例StreamingContext。

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);
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}")>]
new System.Collections.Specialized.OrderedDictionary : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Collections.Specialized.OrderedDictionary
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的實作。

適用於