Enumerable::Single<TSource> Method (IEnumerable<TSource>^)
Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.
Assembly: System.Core (in System.Core.dll)
public: generic<typename TSource> [ExtensionAttribute] static TSource Single( IEnumerable<TSource>^ source )
The single element of the input sequence.
The type of the elements of source.
The following code example demonstrates how to useto select the only element of an array.
The following code example demonstrates thatthrows an exception when the sequence does not contain exactly one element.
Available since 8
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 8.1