Javatpoint Logo
Javatpoint Logo

LINQ Last() Method

The last () Method in LINQ is used to return the last element from the list/collection. LINQ Last() method will throw an exception in case if the list/collection returns no elements.

Syntax of LINQ Last() method

From the above syntax, we are trying to fetch the last element from the "objList" using LINQ Last () method.

Example of LINQ Last() in Method Syntax

Here is the example of LINQ Last () operator in method syntax to get the last element from the list.

From the above code, we are getting the last element from the "ListObj" list by using the LINQ Last () method.

OUTPUT:

LINQ Last() Method

Example of LINQ Last () operator in Query Syntax

OUTPUT:

LINQ Last() 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