Click or drag to resize

CollectionExtensions.Middle<T> Method

Gets the middle item(s) from an enumeration, i.e., one return item for odd lengths, two for even lengths.

Namespace: GSF.Collections
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.239-beta+5928cebde0dd955df84e791f5ea67acbd192773e
Syntax
public static IEnumerable<T> Middle<T>(
	this IEnumerable<T> source
)
View Source

Parameters

source  IEnumerable<T>
An enumeration over which to find the middle element(s).

Type Parameters

T
Type of elements in the source

Return Value

IEnumerable<T>
The middle item(s) from an enumeration, or null if source is null.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<T>. 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).
Remarks
If enumeration length is even, two items will be returned representing the items in the middle of the set; otherwise, if the enumeration length is odd, one item will be returned from exactly the middle of the set.
See Also