C# List Reverse()
Description
List
reverses the order of the elements
in the entire List
Syntax
public void Reverse()
Example
The following example demonstrates both overloads of the Reverse method.
/* ww w .j a va 2 s . c o m*/
using System;
using System.Collections.Generic;
public class Example
{
public static void Main()
{
List<string> myData = new List<string>();
myData.Add("C");
myData.Add("B");
myData.Add("newValue");
foreach(string myD in myData)
{
Console.WriteLine(myD);
}
myData.Reverse();
Console.WriteLine();
foreach(string myD in myData)
{
Console.WriteLine(myD);
}
myData.Reverse(1, 4);
Console.WriteLine();
foreach(string myD in myData)
{
Console.WriteLine(myD);
}
}
}
The code above generates the following result.