IEnumerableExtensionsGroupByIntoItemCountT, TKey Method
Groups the elements of a sequence according to a specified key selector function
and returns a DictionaryTKey, TValue dictionary on which
{.key = element} and {.value = element count}.
Namespace: DevCase.Extensions.IEnumerableExtensionsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[EditorBrowsableAttribute(EditorBrowsableState.Always)]
public static Dictionary<TKey, int> GroupByIntoItemCount<T, TKey>(
this IEnumerable<T> sequence,
Func<T, TKey> keySelector
)
<ExtensionAttribute>
<EditorBrowsableAttribute(EditorBrowsableState.Always)>
Public Shared Function GroupByIntoItemCount(Of T, TKey) (
sequence As IEnumerable(Of T),
keySelector As Func(Of T, TKey)
) As Dictionary(Of TKey, Integer)
Dim sequence As IEnumerable(Of T)
Dim keySelector As Func(Of T, TKey)
Dim returnValue As Dictionary(Of TKey, Integer)
returnValue = sequence.GroupByIntoItemCount(keySelector)
public:
[ExtensionAttribute]
[EditorBrowsableAttribute(EditorBrowsableState::Always)]
generic<typename T, typename TKey>
static Dictionary<TKey, int>^ GroupByIntoItemCount(
IEnumerable<T>^ sequence,
Func<T, TKey>^ keySelector
)
[<ExtensionAttribute>]
[<EditorBrowsableAttribute(EditorBrowsableState.Always)>]
static member GroupByIntoItemCount :
sequence : IEnumerable<'T> *
keySelector : Func<'T, 'TKey> -> Dictionary<'TKey, int>
No code example is currently available or this language may not be supported.
- sequence IEnumerableT
-
The source sequence.
- keySelector FuncT, TKey
-
A function to extract the key for each element.
- T
-
The type of the source elements.
- TKey
-
The type of the key returned by keySelector.
DictionaryTKey,
Int32
The resulting
DictionaryTKey, TValue.
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableT. 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).
This is a code example.
No code example is currently available or this language may not be supported.
Dim sequence As IEnumerable(Of String) = {"a", "A", "c", "d", "b", "b", "b", "b", "b"}
Dim groups As Dictionary(Of String, Integer) = sequence.GroupByIntoItemCount(Function(str As String) str)
For Each group As KeyValuePair(Of String, Integer) In groups
Console.WriteLine($"{NameOf(group.Key)}: {group.Key}; {NameOf(group.Value)}: {group.Value}")
Next group
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.