Click or drag to resize

EnumerableExtensions.TryGetSingleElement<T> Method

Try to get the one and only element of the collection.

Namespace: Altaxo.Collections
Assembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3261.0 (4.8.3261.0)
Syntax
C#
public static bool TryGetSingleElement<T>(
	this IEnumerable<T> org,
	out T singleElement
)

Parameters

org  IEnumerable<T>
The enumeration.
singleElement  T
If the enumeration contains exactly one element, this parameter contains the element. Otherwise, the parameter contains the default for this type.

Type Parameters

T
Type of the elements of the enumeration.

Return Value

Boolean
true if the specified enumeration contains excactly one element; otherwise, false.

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).
Exceptions
ExceptionCondition
ArgumentNullExceptionorg
See Also