ArrayList.Reverse() Method with range
C# Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | class Program { static void Main(string[] args) { ArrayList colors = new ArrayList() { "DimGray", "Gold", "Green", "Ivory", "LightSalmon" }; Console.WriteLine("ArrayList Elements...."); foreach (string color in colors) { Console.WriteLine(color); } colors.Reverse(1, 3); Console.WriteLine(); Console.WriteLine("After Call Reverse(index 1, count 3) Method"); Console.WriteLine("Now ArrayList Elements...."); foreach (string color in colors) { Console.WriteLine(color); } Console.ReadLine(); } } |
Output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ArrayList Elements.... DimGray Gold Green Ivory LightSalmon After Call Reverse(index 1, count 3) Method Now ArrayList Elements.... DimGray Ivory Green Gold LightSalmon |