Whetstone Class reference
Whetstone Class reference
Whetstone
WhetStone Namespaces
WhetStone.Looping
single Class
single Methods
SingleOrDefault(T) Method
single
SingleOrDefault
T
Method
Get the element of an
IEnumerable
T
if it is alone, a default element if it empty, or throw exception otherwise.
Namespace:
WhetStone.Looping
Assembly:
WhetStone (in WhetStone.dll) Version: 1.0.4.0 (1.0.0.0)
Syntax
C#
Copy
public
static
T
SingleOrDefault
<T>(
this
IEnumerable
<T>
this
, T
default
)
Parameters
this
Type:
System.Collections.Generic
IEnumerable
T
The
IEnumerable
T
to use.
default
Type:
T
The value to return if
this
is empty.
Type Parameters
T
The type of the
IEnumerable
T
Return Value
Type:
T
The single element of
this
, or
default
if none exist.
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
Exception
Condition
InvalidOperationException
If the argument contains more than one element.
See Also
Reference
single Class
WhetStone.Looping Namespace