using System.Collections; ArrayList list = new ArrayList(); list.Add("apple"); list.Add("banana"); list.Add("cherry"); list.Add("date"); bool containsBanana = list.Contains("banana"); // true bool containsGrape = list.Contains("grape"); // false
using System.Collections; ArrayList list = new ArrayList(); list.Add(10); list.Add(15); list.Add(20); list.Add(25); bool containsEvenNumber = list.Contains(x => (int)x % 2 == 0); // true bool containsNegativeNumber = list.Contains(x => (int)x < 0); // falseThis example shows how to use the Contains method with a lambda expression to check if there are any even numbers in the ArrayList. The System.Collections ArrayList class is part of the core .NET Framework Class library.