OrderedDictionary<TKey,TValue> 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
OrderedDictionary<TKey,TValue>()
初始化一個空的類別新實例 OrderedDictionary<TKey,TValue> ,該類別為空,擁有預設初始容量,並使用該金鑰類型的預設等號比較器。
public:
OrderedDictionary();
public OrderedDictionary();
Public Sub New ()
適用於
OrderedDictionary<TKey,TValue>(IDictionary<TKey,TValue>)
初始化一個包含從指定OrderedDictionary<TKey,TValue>元素複製的類別新實例IDictionary<TKey,TValue>,並使用該鍵型別的預設等號比較器。
public:
OrderedDictionary(System::Collections::Generic::IDictionary<TKey, TValue> ^ dictionary);
public OrderedDictionary(System.Collections.Generic.IDictionary<TKey,TValue> dictionary);
new System.Collections.Generic.OrderedDictionary<'Key, 'Value> : System.Collections.Generic.IDictionary<'Key, 'Value> -> System.Collections.Generic.OrderedDictionary<'Key, 'Value>
Public Sub New (dictionary As IDictionary(Of TKey, TValue))
參數
- dictionary
- IDictionary<TKey,TValue>
其 IDictionary<TKey,TValue> 元素會被複製到新的 OrderedDictionary<TKey,TValue>。 新集合中元素的初始順序即為從所提供字典中枚舉元素的順序。
例外狀況
dictionary 是 null。
適用於
OrderedDictionary<TKey,TValue>(IEnumerable<KeyValuePair<TKey,TValue>>)
初始化一個包含從指定OrderedDictionary<TKey,TValue>元素複製的類別新實例IEnumerable<T>,並使用該鍵型別的預設等號比較器。
public:
OrderedDictionary(System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<TKey, TValue>> ^ collection);
public OrderedDictionary(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> collection);
new System.Collections.Generic.OrderedDictionary<'Key, 'Value> : seq<System.Collections.Generic.KeyValuePair<'Key, 'Value>> -> System.Collections.Generic.OrderedDictionary<'Key, 'Value>
Public Sub New (collection As IEnumerable(Of KeyValuePair(Of TKey, TValue)))
參數
- collection
- IEnumerable<KeyValuePair<TKey,TValue>>
其 IEnumerable<T> 元素會被複製到新的 OrderedDictionary<TKey,TValue>。 新集合中元素的初始順序是從所提供集合中枚舉元素的順序。
例外狀況
collection 是 null。
適用於
OrderedDictionary<TKey,TValue>(IEqualityComparer<TKey>)
初始化一個新的類別實例,該實例 OrderedDictionary<TKey,TValue> 為空,擁有預設初始容量,並使用指定的 IEqualityComparer<T>。
public:
OrderedDictionary(System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public OrderedDictionary(System.Collections.Generic.IEqualityComparer<TKey>? comparer);
new System.Collections.Generic.OrderedDictionary<'Key, 'Value> : System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.OrderedDictionary<'Key, 'Value>
Public Sub New (comparer As IEqualityComparer(Of TKey))
參數
- comparer
- IEqualityComparer<TKey>
比較金鑰時使用的實作, IEqualityComparer<T> 或 null 是使用金 EqualityComparer<T> 鑰類型預設的實作。
適用於
OrderedDictionary<TKey,TValue>(Int32)
初始化一個空的類別實例,該實例 OrderedDictionary<TKey,TValue> 具有指定的初始容量,並使用該鍵型別的預設等式比較器。
public:
OrderedDictionary(int capacity);
public OrderedDictionary(int capacity);
new System.Collections.Generic.OrderedDictionary<'Key, 'Value> : int -> System.Collections.Generic.OrderedDictionary<'Key, 'Value>
Public Sub New (capacity As Integer)
參數
- capacity
- Int32
初始可包含的元素 OrderedDictionary<TKey,TValue> 數量。
例外狀況
容量小於0。
適用於
OrderedDictionary<TKey,TValue>(IDictionary<TKey,TValue>, IEqualityComparer<TKey>)
初始化一個包含從指定OrderedDictionary<TKey,TValue>元素複製的類別的新實例IDictionary<TKey,TValue>,並使用指定的 IEqualityComparer<T>。
public:
OrderedDictionary(System::Collections::Generic::IDictionary<TKey, TValue> ^ dictionary, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public OrderedDictionary(System.Collections.Generic.IDictionary<TKey,TValue> dictionary, System.Collections.Generic.IEqualityComparer<TKey>? comparer);
new System.Collections.Generic.OrderedDictionary<'Key, 'Value> : System.Collections.Generic.IDictionary<'Key, 'Value> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.OrderedDictionary<'Key, 'Value>
Public Sub New (dictionary As IDictionary(Of TKey, TValue), comparer As IEqualityComparer(Of TKey))
參數
- dictionary
- IDictionary<TKey,TValue>
其 IDictionary<TKey,TValue> 元素會被複製到新的 OrderedDictionary<TKey,TValue>。 新集合中元素的初始順序即為從所提供字典中枚舉元素的順序。
- comparer
- IEqualityComparer<TKey>
比較金鑰時使用的實作, IEqualityComparer<T> 或 null 是使用金 EqualityComparer<T> 鑰類型預設的實作。
例外狀況
dictionary 是 null。
適用於
OrderedDictionary<TKey,TValue>(IEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>)
初始化一個包含從指定OrderedDictionary<TKey,TValue>元素複製的類別的新實例IEnumerable<T>,並使用指定的 IEqualityComparer<T>。
public:
OrderedDictionary(System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<TKey, TValue>> ^ collection, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public OrderedDictionary(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> collection, System.Collections.Generic.IEqualityComparer<TKey>? comparer);
new System.Collections.Generic.OrderedDictionary<'Key, 'Value> : seq<System.Collections.Generic.KeyValuePair<'Key, 'Value>> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.OrderedDictionary<'Key, 'Value>
Public Sub New (collection As IEnumerable(Of KeyValuePair(Of TKey, TValue)), comparer As IEqualityComparer(Of TKey))
參數
- collection
- IEnumerable<KeyValuePair<TKey,TValue>>
其 IEnumerable<T> 元素會被複製到新的 OrderedDictionary<TKey,TValue>。 新集合中元素的初始順序是從所提供集合中枚舉元素的順序。
- comparer
- IEqualityComparer<TKey>
比較金鑰時使用的實作, IEqualityComparer<T> 或 null 是使用金 EqualityComparer<T> 鑰類型預設的實作。
例外狀況
collection 是 null。
適用於
OrderedDictionary<TKey,TValue>(Int32, IEqualityComparer<TKey>)
初始化一個空的類別新實例,該實例 OrderedDictionary<TKey,TValue> 為空,擁有指定的初始容量,並使用指定的 IEqualityComparer<T>。
public:
OrderedDictionary(int capacity, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public OrderedDictionary(int capacity, System.Collections.Generic.IEqualityComparer<TKey>? comparer);
new System.Collections.Generic.OrderedDictionary<'Key, 'Value> : int * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.OrderedDictionary<'Key, 'Value>
Public Sub New (capacity As Integer, comparer As IEqualityComparer(Of TKey))
參數
- capacity
- Int32
初始可包含的元素 OrderedDictionary<TKey,TValue> 數量。
- comparer
- IEqualityComparer<TKey>
比較金鑰時使用的實作, IEqualityComparer<T> 或 null 是使用金 EqualityComparer<T> 鑰類型預設的實作。
例外狀況
容量小於0。