Enumerable.GroupBy — grouping by a key
Enumerable.GroupBy divides a sequence into groups using a selected key. Each group exposes its key through Key, and its elements can be enumerated directly as a sequence.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
Enumerable.GroupBy divides a sequence into groups using a selected key. Each group exposes its key through Key, and its elements can be enumerated directly as a sequence.
Enumerable.GroupJoin: practical reference: For each outer element, creates a pair with the sequence of all inner elements having an equal key, including an empty sequence.
Enumerable.Intersect: practical reference: The deferred result returns unique elements of the first source also present in the second under the comparer.
Enumerable.Join: practical reference: Performs an inner join: calls resultSelector for every equal-key pair, while an element without a match is omitted.
Enumerable.Last: practical reference: Returns the last element or last predicate match; for a general IEnumerable<T> it normally reads the entire source.
Enumerable.LastOrDefault: practical reference: Returns the last element or predicate match; when absent it returns default(T) or an explicitly supplied default value.
Enumerable.Max: practical reference: Immediately enumerates and selects the greatest value or greatest selector result under the appropriate comparer.
Enumerable.Min: practical reference: Immediately enumerates and selects the smallest value or smallest selector result under the appropriate comparer.
Enumerable.OrderBy: practical reference: During enumeration, this deferred operation buffers the whole source and performs a stable ascending sort by key.
Enumerable.OrderByDescending: practical reference: Like OrderBy, but sorts the primary key descending. The sort remains stable.
Enumerable.Range: practical reference: Creates a deferred sequence of count consecutive Int32 values beginning at start.
Enumerable.Repeat: practical reference: Creates a deferred sequence containing the same value count times.
Enumerable.Select: practical reference: The deferred projection calls selector for each enumerated element and returns its result. The indexed overload passes a zero-based index.
Enumerable.SelectMany: practical reference: The deferred projection calls a collection selector and flattens the returned sequences into one result.
Enumerable.Single: practical reference: Requires exactly one element or match and enumerates far enough to detect a second.
Enumerable.SingleOrDefault: practical reference: Allows zero or one result; zero returns default(T), but two results remain an error.
Enumerable.Skip: practical reference: The deferred operation skips the first count elements and then returns the remainder.
Enumerable.SkipWhile: practical reference: Skips initial elements while the predicate is true; after the first false it returns every remaining element without skipping again.
Enumerable.Sum: practical reference: Immediately enumerates and adds values in the overload-specific type; nullable overloads ignore null.
Enumerable.Take: practical reference: The deferred operation returns at most the first count elements and ends enumeration when the limit is reached.
Enumerable.TakeWhile: practical reference: Returns the initial segment while the predicate is true and stops at the first false.
Enumerable.ThenBy: practical reference: Adds a stable ascending secondary key to an existing IOrderedEnumerable<T>.
Enumerable.ThenByDescending: practical reference: Adds a stable descending secondary key while preserving the priority of earlier keys.
Enumerable.ToArray: practical reference: Immediately enumerates and copies elements into a new fixed-length array.