MoreLinq
AssertCount<(Of <(<'TSource>)>)> Method (source, count, errorSelector)
NamespacesMoreLinqMoreEnumerableAssertCount<(Of <<'(TSource>)>>)(IEnumerable<(Of <<'(TSource>)>>), Int32, Func<(Of <<'(Int32, Int32, Exception>)>>))
Asserts that a source sequence contains a given count of elements. A parameter specifies the exception to be thrown.
Declaration Syntax
C#Visual BasicVisual C++
public static IEnumerable<TSource> AssertCount<TSource>(
	this IEnumerable<TSource> source,
	int count,
	Func<int, int, Exception> errorSelector
)
<ExtensionAttribute> _
Public Shared Function AssertCount(Of TSource) ( _
	source As IEnumerable(Of TSource), _
	count As Integer, _
	errorSelector As Func(Of Integer, Integer, Exception) _
) As IEnumerable(Of TSource)
public:
[ExtensionAttribute]
generic<typename TSource>
static IEnumerable<TSource>^ AssertCount(
	IEnumerable<TSource>^ source, 
	int count, 
	Func<int, int, Exception^>^ errorSelector
)
Generic Template Parameters
TSource
Type of elements in source sequence.
Parameters
source (IEnumerable<(Of <(<'TSource>)>)>)
Source sequence.
count (Int32)
Count to assert.
errorSelector (Func<(Of <(<'Int32, Int32, Exception>)>)>)
Function that returns the Exception object to throw.
Return Value
Returns the original sequence as long it is contains the number of elements specified by count. Otherwise it throws the Exception object returned by calling errorSelector.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<(Of <(<'TSource>)>)>. When you use instance method syntax to call this method, omit the first parameter.
Remarks
This operator uses deferred execution and streams its results.

Assembly: MoreLinq (Module: MoreLinq.dll) Version: 1.0.16006.0 (1.0.16006.1845)