ArrayList list = new ArrayList(); list.Add(1); list.Add(2); list.Add(3); int index = list.IndexOf(2); // Returns 1
class Person { public string Name { get; set; } public int Age { get; set; } } ArrayList people = new ArrayList(); people.Add(new Person { Name = "John", Age = 25 }); people.Add(new Person { Name = "Mary", Age = 30 }); Person personToFind = new Person { Name = "John", Age = 25 }; int index = people.IndexOf(personToFind); // Returns 0In these examples, the ArrayList is part of the base class library of C# and is not part of any specific package or library.