IImmutableDictionary<TKey,TValue> IImmutableDictionary<TKey,TValue> IImmutableDictionary<TKey,TValue> IImmutableDictionary<TKey,TValue> Interface

定义

表示键/值对的不可变集合。Represents an immutable collection of key/value pairs.

NuGet 包System.Collections.Immutable关于不可变集合和安装方法NuGet package: System.Collections.Immutable (about immutable collections and how to install)

generic <typename TKey, typename TValue>
public interface class IImmutableDictionary : System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<TKey, TValue>>, System::Collections::Generic::IReadOnlyCollection<System::Collections::Generic::KeyValuePair<TKey, TValue>>, System::Collections::Generic::IReadOnlyDictionary<TKey, TValue>
public interface IImmutableDictionary<TKey,TValue> : System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>>, System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>, System.Collections.Generic.IReadOnlyDictionary<TKey,TValue>
type IImmutableDictionary<'Key, 'Value> = interface
    interface seq<KeyValuePair<'Key, 'Value>>
    interface IEnumerable
    interface IReadOnlyCollection<KeyValuePair<'Key, 'Value>>
    interface IReadOnlyDictionary<'Key, 'Value>
Public Interface IImmutableDictionary(Of TKey, TValue)
Implements IEnumerable(Of KeyValuePair(Of TKey, TValue)), IReadOnlyCollection(Of KeyValuePair(Of TKey, TValue)), IReadOnlyDictionary(Of TKey, TValue)

类型参数

TKey

字典中键的类型。The type of keys in the dictionary.

TValue

字典中值的类型。The type of values in the dictionary.

派生
实现

注解

IImmutableDictionary<TKey,TValue>需要一个相等比较器实现来确定两个键是否相等。A IImmutableDictionary<TKey,TValue> requires an equality comparer implementation to determine if two keys are equal.

方法

Add(TKey, TValue) Add(TKey, TValue) Add(TKey, TValue) Add(TKey, TValue)

将具有指定键和值的元素添加到字典。Adds an element with the specified key and value to the dictionary.

AddRange(IEnumerable<KeyValuePair<TKey,TValue>>) AddRange(IEnumerable<KeyValuePair<TKey,TValue>>) AddRange(IEnumerable<KeyValuePair<TKey,TValue>>) AddRange(IEnumerable<KeyValuePair<TKey,TValue>>)

将指定的键/值对添加到字典中。Adds the specified key/value pairs to the dictionary.

Clear() Clear() Clear() Clear()

检索排序规则和键/值比较规则与此字典实例相同的空字典。Retrieves an empty dictionary that has the same ordering and key/value comparison rules as this dictionary instance.

Contains(KeyValuePair<TKey,TValue>) Contains(KeyValuePair<TKey,TValue>) Contains(KeyValuePair<TKey,TValue>) Contains(KeyValuePair<TKey,TValue>)

确定不可变字典是否包含指定的键/值对。Determines whether the immutable dictionary contains the specified key/value pair.

ContainsKey(TKey) ContainsKey(TKey) ContainsKey(TKey) ContainsKey(TKey)

确定只读字典是否包含具有指定键的元素。Determines whether the read-only dictionary contains an element that has the specified key.

(Inherited from IReadOnlyDictionary<TKey,TValue>)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

返回循环访问集合的枚举数。Returns an enumerator that iterates through a collection.

(Inherited from IEnumerable)
Remove(TKey) Remove(TKey) Remove(TKey) Remove(TKey)

从不可变字典中移除具有指定键的元素。Removes the element with the specified key from the immutable dictionary.

RemoveRange(IEnumerable<TKey>) RemoveRange(IEnumerable<TKey>) RemoveRange(IEnumerable<TKey>) RemoveRange(IEnumerable<TKey>)

从不可变字典中移除具有指定键的元素。Removes the elements with the specified keys from the immutable dictionary.

SetItem(TKey, TValue) SetItem(TKey, TValue) SetItem(TKey, TValue) SetItem(TKey, TValue)

在不可变字典中设置指定的键和值,可能的设置方法是覆盖该键的现有值。Sets the specified key and value in the immutable dictionary, possibly overwriting an existing value for the key.

SetItems(IEnumerable<KeyValuePair<TKey,TValue>>) SetItems(IEnumerable<KeyValuePair<TKey,TValue>>) SetItems(IEnumerable<KeyValuePair<TKey,TValue>>) SetItems(IEnumerable<KeyValuePair<TKey,TValue>>)

在不可变字典中设置指定的键/值对,可能的设置方法是覆盖键的现有值。Sets the specified key/value pairs in the immutable dictionary, possibly overwriting existing values for the keys.

TryGetKey(TKey, TKey) TryGetKey(TKey, TKey) TryGetKey(TKey, TKey) TryGetKey(TKey, TKey)

确定此字典是否包含指定的键。Determines whether this dictionary contains a specified key.

TryGetValue(TKey, TValue) TryGetValue(TKey, TValue) TryGetValue(TKey, TValue) TryGetValue(TKey, TValue)

获取与指定的键关联的值。Gets the value that is associated with the specified key.

(Inherited from IReadOnlyDictionary<TKey,TValue>)

属性

Count Count Count Count

获取集合中的元素数。Gets the number of elements in the collection.

(Inherited from IReadOnlyCollection<T>)
Item[TKey] Item[TKey] Item[TKey] Item[TKey]

获取在只读目录中有指定键的元素。Gets the element that has the specified key in the read-only dictionary.

(Inherited from IReadOnlyDictionary<TKey,TValue>)
Keys Keys Keys Keys

获取包含只读字典中的密钥的可枚举集合。Gets an enumerable collection that contains the keys in the read-only dictionary.

(Inherited from IReadOnlyDictionary<TKey,TValue>)
Values Values Values Values

获取包含只读字典中的值的可枚举集合。Gets an enumerable collection that contains the values in the read-only dictionary.

(Inherited from IReadOnlyDictionary<TKey,TValue>)

扩展方法

GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey) GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey) GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey) GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey)
GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue) GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue) GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue) GetValueOrDefault<TKey,TValue>(IReadOnlyDictionary<TKey,TValue>, TKey, TValue)
Contains<TKey,TValue>(IImmutableDictionary<TKey,TValue>, TKey, TValue) Contains<TKey,TValue>(IImmutableDictionary<TKey,TValue>, TKey, TValue) Contains<TKey,TValue>(IImmutableDictionary<TKey,TValue>, TKey, TValue) Contains<TKey,TValue>(IImmutableDictionary<TKey,TValue>, TKey, TValue)

确定指定的不可变字典是否包含指定的键/值对。Determines whether the specified immutable dictionary contains the specified key/value pair.

GetValueOrDefault<TKey,TValue>(IImmutableDictionary<TKey,TValue>, TKey) GetValueOrDefault<TKey,TValue>(IImmutableDictionary<TKey,TValue>, TKey) GetValueOrDefault<TKey,TValue>(IImmutableDictionary<TKey,TValue>, TKey) GetValueOrDefault<TKey,TValue>(IImmutableDictionary<TKey,TValue>, TKey)

如果字典中存在匹配的键,则获取给定键的值。Gets the value for a given key if a matching key exists in the dictionary.

GetValueOrDefault<TKey,TValue>(IImmutableDictionary<TKey,TValue>, TKey, TValue) GetValueOrDefault<TKey,TValue>(IImmutableDictionary<TKey,TValue>, TKey, TValue) GetValueOrDefault<TKey,TValue>(IImmutableDictionary<TKey,TValue>, TKey, TValue) GetValueOrDefault<TKey,TValue>(IImmutableDictionary<TKey,TValue>, TKey, TValue)

如果字典中存在匹配的键,则获取给定键的值。Gets the value for a given key if a matching key exists in the dictionary.

CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>)

在给定其泛型参数 TDataTable 的输入 DataRow 对象的情况下,返回包含 IEnumerable<T> 对象副本的 DataRowReturns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个节点的上级。Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个节点的上级。Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子代节点的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个元素和文档的子代元素。Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个元素和文档的子代元素。Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>)

返回源集合中每个元素和文档的子元素的集合。Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName)

返回源集合中经过筛选的每个元素和文档的子元素集合。Returns a filtered collection of the child elements of every element and document in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>)

返回节点集合(其中包含源集合中的所有节点),并按文档顺序排列。Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子节点集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>)

将源集合中的每个节点从其父节点中移除。Removes every node in the source collection from its parent node.

适用于