ImmutableDictionary.ToImmutableDictionary<TSource, TKey> Method (IEnumerable<TSource>, Func<TSource, TKey>)

 

Constructs an immutable dictionary from an existing collection of elements, applying a transformation function to the source keys.

Namespace:   System.Collections.Immutable
Assembly:  System.Collections.Immutable (in System.Collections.Immutable.dll)

public static ImmutableDictionary<TKey, TSource> ToImmutableDictionary<TSource, TKey>(
	this IEnumerable<TSource> source,
	Func<TSource, TKey> keySelector
)

Parameters

source
Type: System.Collections.Generic.IEnumerable<TSource>

The source collection used to generate the immutable dictionary.

keySelector
Type: System.Func<TSource, TKey>

The function used to transform keys for the immutable dictionary.

Return Value

Type: System.Collections.Immutable.ImmutableDictionary<TKey, TSource>

The immutable dictionary that contains elements from source, with keys transformed by applying keySelector.

Type Parameters

TSource

The type of element in the source collection.

TKey

The type of key in the resulting immutable dictionary.

Return to top
Show: