ArrayList list = new ArrayList(); list.Add("apple"); list.Add("orange"); list.Add("banana"); int index = list.IndexOf("orange");
ArrayList list = new ArrayList(); list.Add(1); list.Add(2); list.Add(3); list.Add(4); list.Add(5); int index = list.IndexOf(3);In this example, an `ArrayList` of integer elements is created and five elements are added to the list. The `IndexOf` method is used to find the index of the value 3 in the list, which returns the value 2. The `IndexOf` method is included in the `System.Collections` namespace, which is part of the .NET Framework Class Library.