ArrayList IndexOf() 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 | class Program { static void Main(string[] args) { ArrayList colors = new ArrayList() { "ForestGreen", "Orange", "SkyBlue", "Navy", "Orange", "Olive" }; Console.WriteLine("ArrayList Elements...."); foreach (string color in colors) { Console.WriteLine(color); } Console.WriteLine(); Console.WriteLine("IndexOf(object Orange, startIndex 2, count 4)"); Console.WriteLine("Index of 'Orange': " + colors.IndexOf("Orange", 2, 4)); Console.ReadLine(); } } |
Output:
1 2 3 4 5 6 7 8 9 10 11 12 | ArrayList Elements.... ForestGreen Orange SkyBlue Navy Orange Olive IndexOf(object Orange, startIndex 2, count 4) Index of 'Orange': 4 |