CollectionExtensionsMajorityT(IEnumerableT, Boolean, IEqualityComparerT) Method

Returns the majority value in the collection, or default type value if no item represents the majority.

Definition

Namespace: Gemstone.Collections.CollectionExtensions
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.110 -- Release Build+3e0464f4461df4d3e1175b13966eb47ff832554d
public static T Majority<T>(
	this IEnumerable<T>? source,
	bool forwardSearch = true,
	IEqualityComparer<T>? comparer = null
)

Parameters

source  IEnumerableT
An enumeration over which to find the majority element.
forwardSearch  Boolean  (Optional)
true to search forward in source; otherwise false to search backwards.
comparer  IEqualityComparerT  (Optional)
The IEqualityComparerT implementation to use when comparing keys, or null to use the default comparer for the type of the key.

Type Parameters

T
Type of elements in the source.

Return Value

T
The majority value in the collection.

Usage Note

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).

See Also