Skip to main content
.NET Framework Class Library
EnumerableReverseTSource Method

Inverts the order of the elements in a sequence.

Namespace:   System.Linq
Assemblies:   System.Linq (in System.Linq.dll)
  System.Core (in System.Core.dll)
<[%$TOPIC/bb358497_en-us_VS_110_1_0_0_0_0%]> _
Public Shared Function Reverse(Of TSource) ( _
	source As [%$TOPIC/bb358497_en-us_VS_110_1_0_0_0_1%](Of TSource) _
) As [%$TOPIC/bb358497_en-us_VS_110_1_0_0_0_2%](Of TSource)
public static [%$TOPIC/bb358497_en-us_VS_110_1_0_1_0_0%]<TSource> Reverse<TSource>(
	this [%$TOPIC/bb358497_en-us_VS_110_1_0_1_0_1%]<TSource> source
generic<typename TSource>
static [%$TOPIC/bb358497_en-us_VS_110_1_0_2_0_1%]<TSource>^ Reverse(
	[%$TOPIC/bb358497_en-us_VS_110_1_0_2_0_2%]<TSource>^ source
static member Reverse : 
        source:[%$TOPIC/bb358497_en-us_VS_110_1_0_3_0_0%]<'TSource> -> [%$TOPIC/bb358497_en-us_VS_110_1_0_3_0_1%]<'TSource> 

Type Parameters


The type of the elements of source.


Type: System.Collections.GenericIEnumerableTSource

A sequence of values to reverse.

Return Value

Type: System.Collections.GenericIEnumerableTSource
A sequence whose elements correspond to those of the input sequence in reverse order.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableTSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

source is .


This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its GetEnumerator method directly or by using foreach in Visual C# or For Each in Visual Basic.

Unlike OrderBy, this sorting method does not consider the actual values themselves in determining the order. Rather, it just returns the elements in the reverse order from which they are produced by the underlying source.


The following code example demonstrates how to use ReverseTSource to reverse the order of elements in an array.

        ' Create a List of Char values. 
        Dim appleLetters As New List(Of Char)(New Char() _
                                              {"a"c, "P"c, "P"c, "L"c, "E"c})

        ' Reverse the order of the elements in the list. 
        ' (We have to call AsEnumerable() in order to 
        ' use System.Linq.Enumerable's Reverse() method. 
        Dim reversed() As Char = _

        Dim output As New System.Text.StringBuilder
        For Each chr As Char In reversed
            output.Append(chr & " ")

        ' Display the output.

        ' This code produces the following output: 
        ' E L P P a 
char[] apple = { 'a', 'p', 'p', 'l', 'e' };

            char[] reversed = apple.Reverse().ToArray();

            foreach (char chr in reversed)
                Console.Write(chr + " ");

             This code produces the following output:

             e l p p a
Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.