LINQ Last() MethodThe 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() methodFrom the above syntax, we are trying to fetch the last element from the "objList" using LINQ Last () method. Example of LINQ Last() in Method SyntaxHere 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: Example of LINQ Last () operator in Query SyntaxOUTPUT:
Next TopicLINQ LastOrDefault() Method
|