EnumerableExtensionsToStringKeyedDictionaryTSource, TValue(IEnumerableTSource, FuncTSource, String, FuncTSource, TValue, StringSegmentComparer) Method

Creates a StringKeyedDictionaryTValue from an IEnumerableT instance using the specified key and value selector delegates and a comparer.

Definition

Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0
C#
public static StringKeyedDictionary<TValue> ToStringKeyedDictionary<TSource, TValue>(
	this IEnumerable<TSource> source,
	Func<TSource, string> keySelector,
	Func<TSource, TValue> valueSelector,
	StringSegmentComparer? comparer = null
)

Parameters

source  IEnumerableTSource
The source collection to create a StringKeyedDictionaryTValue from.
keySelector  FuncTSource, String
A delegate to produce a key for each element in the source collection.
valueSelector  FuncTSource, TValue
A delegate to produce a value for each element in the source collection.
comparer  StringSegmentComparer  (Optional)
A StringSegmentComparer to compare keys. If , then ordinal comparison will be used. This parameter is optional.
Default value: .

Type Parameters

TSource
The type of the elements in the source collection.
TValue
The type of the value returned by the specified valueSelector.

Return Value

StringKeyedDictionaryTValue
A StringKeyedDictionaryTValue that contains values of type TValue created by the specified valueSelector for each elements in the source collection.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableTSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also