Reverse the order of the elements in List sub range in CSharp
Description
The following code shows how to reverse the order of the elements in List sub range.
Example
using System;//from w w w.j a v a 2s . c om
using System.Collections.Generic;
public class Example
{
public static void Main()
{
List<string> myData = new List<string>();
myData.Add("A");
myData.Add("B");
myData.Add("C");
myData.Add("D");
myData.Add("E");
myData.Add("F");
myData.Add("G");
myData.Add("H");
myData.Add("newValue");
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.