Reverses the order of the elements in the specified range. : List « Collections Data Structure « C# / C Sharp
- C# / C Sharp
- Collections Data Structure
- List
Reverses the order of the elements in the specified range.
using System;
using System.Collections.Generic;
public class Example
{
public static void Main()
{
List<string> myList = new List<string>();
myList.Add("A");
myList.Add("B");
myList.Add("C");
Console.WriteLine();
foreach (string d in myList)
{
Console.WriteLine(d);
}
myList.Reverse();
Console.WriteLine();
foreach (string d in myList)
{
Console.WriteLine(d);
}
myList.Reverse(1, 4);
Console.WriteLine();
foreach (string d in myList)
{
Console.WriteLine(d);
}
}
}
Related examples in the same category