[This is preliminary documentation and is subject to change.]

Gets last item in collection

Namespace: Tools.CollectionsT.GenericT
Assembly: Tools (in Tools.dll) Version: 1.5.3.38916 (1.5.3.38916)

Syntax

C#
public static T Last<T>(
	this IEnumerable<T> Collection
)
Visual Basic
<ExtensionAttribute> _
Public Shared Function Last(Of T) ( _
	Collection As IEnumerable(Of T) _
) As T
Visual C++
[ExtensionAttribute]
public:
generic<typename T>
static T Last(
	IEnumerable<T>^ Collection
)
F#
static member Last : 
        Collection:IEnumerable<'T> -> 'T 
JScript
JScript does not support generic types or methods.

Parameters

Collection
Type: System.Collections.Generic..::..IEnumerable<(Of <(<'T>)>)>
Collection to obtain item from

Type Parameters

T
Type of items in collection

Return Value

Last item in Collection, or null if Collection is empty

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<(Of <(<'T>)>)>. When you use instance method syntax to call this method, omit the first parameter. For more information, see or .

Remarks

This function have to iterate through whole Collection

Exceptions

ExceptionCondition
System..::..ArgumentNullExceptionCollection is null

See Also