Javatpoint Logo
Javatpoint Logo

LINQ Single() Method

In LINQ, the Single() method is used to return the single element from the collection, which satisfies the condition. In case, if the Single() method found more than one element in collection or no element in the collection, then it will throw the "InvalidOperationException" error.

Syntax of LINQ Single () Method

The syntax of using the LINQ Single () method to get a single element from the collection.

In the above syntax, we are getting the single element from the list using LINQ Single () method.

Example of LINQ Single () Method

Here is the example of the LINQ Single () method to get a single element from the collection.

From the above example, we are getting the single element from the collection "objStudent" using the LINQ Single() operator.

OUTPUT:

LINQ Single() Method





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA