ImmutableDictionary.ToImmutableDictionary 方法

定義

多載

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

列舉索引鍵/值組的序列,並產生其內容的不可變字典。

ToImmutableDictionary<TKey,TValue>(ImmutableDictionary<TKey,TValue>.Builder)

從產生器字典目前內容建立不可變的字典。

ToImmutableDictionary<TKey,TValue>(IEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>)

列舉索引鍵/值組的序列,並使用指定的索引鍵比較子產生不可變的排序字典作為內容。

ToImmutableDictionary<TKey,TValue>(IEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>, IEqualityComparer<TValue>)

列舉索引鍵/值組的序列,並使用指定的索引鍵與值比較子產生其內容的不可變字典。

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>)

列舉及轉換序列,並產生其內容的不可變字典。

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IEqualityComparer<TKey>)

列舉及轉換序列,並使用指定的索引鍵比較子產生其內容的不可變字典。

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IEqualityComparer<TKey>, IEqualityComparer<TValue>)

列舉及轉換序列,並使用指定的索引鍵與值比較子產生其內容的不可變字典。

ToImmutableDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

從現有的項目集合建構不可變的字典,將轉換函式套用至來源索引鍵。

ToImmutableDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根據序列的某些轉換來建構不可變的字典。

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

來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs

列舉索引鍵/值組的序列,並產生其內容的不可變字典。

C#
public static System.Collections.Immutable.ImmutableDictionary<TKey,TValue> ToImmutableDictionary<TKey,TValue> (this System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> source);

類型參數

TKey

字典中的索引鍵類型。

TValue

字典中的值類型。

參數

source
IEnumerable<KeyValuePair<TKey,TValue>>

要列舉的索引鍵/值組的序列。

傳回

不可變的字典,其中包含指定序列中的索引鍵/值組。

適用於

.NET 9 及其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
UWP 10.0

ToImmutableDictionary<TKey,TValue>(ImmutableDictionary<TKey,TValue>.Builder)

來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs

從產生器字典目前內容建立不可變的字典。

C#
public static System.Collections.Immutable.ImmutableDictionary<TKey,TValue> ToImmutableDictionary<TKey,TValue> (this System.Collections.Immutable.ImmutableDictionary<TKey,TValue>.Builder builder);

類型參數

TKey

字典中的索引鍵類型。

TValue

字典中的值類型。

參數

builder
ImmutableDictionary<TKey,TValue>.Builder

產生器,用於建立不可變的字典。

傳回

不可變的字典,其中包含產生器字典的目前內容。

適用於

.NET 9 及其他版本
產品 版本
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9

ToImmutableDictionary<TKey,TValue>(IEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>)

來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs

列舉索引鍵/值組的序列,並使用指定的索引鍵比較子產生不可變的排序字典作為內容。

C#
public static System.Collections.Immutable.ImmutableDictionary<TKey,TValue> ToImmutableDictionary<TKey,TValue> (this System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> source, System.Collections.Generic.IEqualityComparer<TKey> keyComparer);
C#
public static System.Collections.Immutable.ImmutableDictionary<TKey,TValue> ToImmutableDictionary<TKey,TValue> (this System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> source, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer);

類型參數

TKey

字典中的索引鍵類型。

TValue

字典中的值類型。

參數

source
IEnumerable<KeyValuePair<TKey,TValue>>

要列舉的索引鍵/值組的序列。

keyComparer
IEqualityComparer<TKey>

建立不可變字典時使用的索引鍵比較子。

傳回

不可變的字典,其中包含指定序列中的索引鍵/值組。

適用於

.NET 9 及其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
UWP 10.0

ToImmutableDictionary<TKey,TValue>(IEnumerable<KeyValuePair<TKey,TValue>>, IEqualityComparer<TKey>, IEqualityComparer<TValue>)

來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs

列舉索引鍵/值組的序列,並使用指定的索引鍵與值比較子產生其內容的不可變字典。

C#
public static System.Collections.Immutable.ImmutableDictionary<TKey,TValue> ToImmutableDictionary<TKey,TValue> (this System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> source, System.Collections.Generic.IEqualityComparer<TKey> keyComparer, System.Collections.Generic.IEqualityComparer<TValue> valueComparer);
C#
public static System.Collections.Immutable.ImmutableDictionary<TKey,TValue> ToImmutableDictionary<TKey,TValue> (this System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>> source, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer, System.Collections.Generic.IEqualityComparer<TValue>? valueComparer);

類型參數

TKey

字典中的索引鍵類型。

TValue

字典中的值類型。

參數

source
IEnumerable<KeyValuePair<TKey,TValue>>

要列舉的索引鍵/值組的序列。

keyComparer
IEqualityComparer<TKey>

建立不可變字典時使用的索引鍵比較子。

valueComparer
IEqualityComparer<TValue>

不可變字典所使用的值比較子。

傳回

不可變的字典,其中包含指定序列中的索引鍵/值組。

適用於

.NET 9 及其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
UWP 10.0

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>)

來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs

列舉及轉換序列,並產生其內容的不可變字典。

C#
public static System.Collections.Immutable.ImmutableDictionary<TKey,TValue> ToImmutableDictionary<TSource,TKey,TValue> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TValue> elementSelector);

類型參數

TSource

序列中的項目類型。

TKey

所產生字典中的索引鍵類型。

TValue

所產生字典中的值類型。

參數

source
IEnumerable<TSource>

列舉以產生字典的序列。

keySelector
Func<TSource,TKey>

從每個序列項目產生字典的索引鍵的函式。

elementSelector
Func<TSource,TValue>

從每個序列項目產生字典的值的函式。

傳回

不可變的字典,其中包含指定序列的項目。

適用於

.NET 9 及其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
UWP 10.0

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IEqualityComparer<TKey>)

來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs

列舉及轉換序列,並使用指定的索引鍵比較子產生其內容的不可變字典。

C#
public static System.Collections.Immutable.ImmutableDictionary<TKey,TValue> ToImmutableDictionary<TSource,TKey,TValue> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TValue> elementSelector, System.Collections.Generic.IEqualityComparer<TKey> keyComparer);
C#
public static System.Collections.Immutable.ImmutableDictionary<TKey,TValue> ToImmutableDictionary<TSource,TKey,TValue> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TValue> elementSelector, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer);

類型參數

TSource

序列中的項目類型。

TKey

所產生字典中的索引鍵類型。

TValue

所產生字典中的值類型。

參數

source
IEnumerable<TSource>

列舉以產生字典的序列。

keySelector
Func<TSource,TKey>

從每個序列項目產生字典的索引鍵的函式。

elementSelector
Func<TSource,TValue>

從每個序列項目產生字典的值的函式。

keyComparer
IEqualityComparer<TKey>

字典使用的索引鍵比較子。

傳回

不可變的字典,其中包含指定序列的項目。

適用於

.NET 9 及其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
UWP 10.0

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IEqualityComparer<TKey>, IEqualityComparer<TValue>)

來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs

列舉及轉換序列,並使用指定的索引鍵與值比較子產生其內容的不可變字典。

C#
public static System.Collections.Immutable.ImmutableDictionary<TKey,TValue> ToImmutableDictionary<TSource,TKey,TValue> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TValue> elementSelector, System.Collections.Generic.IEqualityComparer<TKey> keyComparer, System.Collections.Generic.IEqualityComparer<TValue> valueComparer);
C#
public static System.Collections.Immutable.ImmutableDictionary<TKey,TValue> ToImmutableDictionary<TSource,TKey,TValue> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,TKey> keySelector, Func<TSource,TValue> elementSelector, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer, System.Collections.Generic.IEqualityComparer<TValue>? valueComparer);

類型參數

TSource

序列中的項目類型。

TKey

所產生字典中的索引鍵類型。

TValue

所產生字典中的值類型。

參數

source
IEnumerable<TSource>

列舉以產生字典的序列。

keySelector
Func<TSource,TKey>

從每個序列項目產生字典的索引鍵的函式。

elementSelector
Func<TSource,TValue>

從每個序列項目產生字典的值的函式。

keyComparer
IEqualityComparer<TKey>

字典使用的索引鍵比較子。

valueComparer
IEqualityComparer<TValue>

字典使用的值比較子。

傳回

不可變的字典,其中包含指定序列的項目。

適用於

.NET 9 及其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
UWP 10.0

ToImmutableDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>)

來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs

從現有的項目集合建構不可變的字典,將轉換函式套用至來源索引鍵。

C#
public static System.Collections.Immutable.ImmutableDictionary<TKey,TSource> ToImmutableDictionary<TSource,TKey> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,TKey> keySelector);

類型參數

TSource

來源集合中的項目類型。

TKey

所產生的不可變字典中的索引鍵類型。

參數

source
IEnumerable<TSource>

用來產生不可變字典的來源集合。

keySelector
Func<TSource,TKey>

用來轉換不可變字典之索引鍵的函式。

傳回

ImmutableDictionary<TKey,TSource>

不可變的字典,其中包含來自 source 的項目,以及藉由套用 keySelector 來轉換的索引鍵。

適用於

.NET 9 及其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
UWP 10.0

ToImmutableDictionary<TSource,TKey>(IEnumerable<TSource>, Func<TSource,TKey>, IEqualityComparer<TKey>)

來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs
來源:
ImmutableDictionary.cs

根據序列的某些轉換來建構不可變的字典。

C#
public static System.Collections.Immutable.ImmutableDictionary<TKey,TSource> ToImmutableDictionary<TSource,TKey> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey> keyComparer);
C#
public static System.Collections.Immutable.ImmutableDictionary<TKey,TSource> ToImmutableDictionary<TSource,TKey> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer);

類型參數

TSource

來源集合中的項目類型。

TKey

所產生的不可變字典中的索引鍵類型。

參數

source
IEnumerable<TSource>

用來產生不可變字典的來源集合。

keySelector
Func<TSource,TKey>

用來轉換不可變字典之索引鍵的函式。

keyComparer
IEqualityComparer<TKey>

字典使用的索引鍵比較子。

傳回

ImmutableDictionary<TKey,TSource>

不可變的字典,其中包含來自 source 的項目,以及藉由套用 keySelector 來轉換的索引鍵。

適用於

.NET 9 及其他版本
產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
UWP 10.0