Post­Sharp Documentation / API Reference / Post­Sharp.​Patterns.​Collections Namespace / Extensions Class / Extensions Methods / Extensions.​To­Advisable­Dictionary Method / Extensions.​To­Advisable­Dictionary(TItem, TKey, TValue) Method (IEnumerable(TItem), Func(TItem, TKey), Func(TItem, TValue))

Extensions.ToAdvisableDictionary<TItem, TKey, TValue> Method (IEnumerable<TItem>, Func<TItem, TKey>, Func<TItem, TValue>)

Converts an IEnumerable<T> into a AdvisableDictionary<TKey, TValue> given a method returning the item key and a method returning the item value.

Namespace:  PostSharp.Patterns.Collections
Assembly:  PostSharp.Patterns.Common (in PostSharp.Patterns.Common.dll) Version: 6.0.18.0 (6.0.18.0)
Syntax
C#
public static AdvisableDictionary<TKey, TValue> ToAdvisableDictionary<TItem, TKey, TValue>(
	this IEnumerable<TItem> collection,
	Func<TItem, TKey> getKeyFunc,
	Func<TItem, TValue> getValueFunc
)

Parameters

collection
Type: System.Collections.Generic.IEnumerable<TItem>
An IEnumerable<T>, or null.
getKeyFunc
Type: System.Func<TItem, TKey>
A method returning the dictionary key given an item of the input collection.
getValueFunc
Type: System.Func<TItem, TValue>
A method returning the dictionary value given an item of the input collection.

Type Parameters

TItem
Type of items in the input collection.
TKey
Type of keys in the output dictionary.
TValue
Type of values in the output dictionary.

Return Value

Type: AdvisableDictionary<TKey, TValue>
A new AdvisableDictionary<TKey, TValue> build from items of the input collection, or null if collection is null.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<TItem>. 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