OrderedDictionary 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 OrderedDictionary 类的新实例。
重载
OrderedDictionary() |
初始化 OrderedDictionary 类的新实例。 |
OrderedDictionary(IEqualityComparer) |
使用指定的比较器初始化 OrderedDictionary 类的新实例。 |
OrderedDictionary(Int32) |
使用指定的初始容量初始化 OrderedDictionary 类的新实例。 |
OrderedDictionary(Int32, IEqualityComparer) |
使用指定初始容量和比较器初始化 OrderedDictionary 类的新实例。 |
OrderedDictionary(SerializationInfo, StreamingContext) |
已过时.
使用指定的 OrderedDictionary 和 SerializationInfo 对象初始化可序列化的 StreamingContext 类的新实例。 |
OrderedDictionary()
- Source:
- OrderedDictionary.cs
- Source:
- OrderedDictionary.cs
- Source:
- 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)
- Source:
- OrderedDictionary.cs
- Source:
- OrderedDictionary.cs
- Source:
- 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)
参数
注解
比较器确定两个键是否相等。 集合中的每个键都必须是唯一的 OrderedDictionary 。 默认比较器是 的键实现 Object.Equals。
自定义比较器支持使用不区分大小写的字符串执行查找等方案。
适用于
OrderedDictionary(Int32)
- Source:
- OrderedDictionary.cs
- Source:
- OrderedDictionary.cs
- Source:
- 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)
- Source:
- OrderedDictionary.cs
- Source:
- OrderedDictionary.cs
- Source:
- 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 集合可以包含的初始元素数。
注解
比较器确定两个键是否相等。 集合中的每个键都必须是唯一的 OrderedDictionary 。 默认比较器是 的键实现 Object.Equals。
自定义比较器支持使用不区分大小写的字符串执行查找等方案。
适用于
OrderedDictionary(SerializationInfo, StreamingContext)
- Source:
- OrderedDictionary.cs
- Source:
- OrderedDictionary.cs
- Source:
- 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);
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。