Mega Code Archive

 
Categories / C# / Collections Data Structure
 

Search for the first occurrence of the duplicated value in the last section of the ArrayList

using System; using System.Collections; public class SamplesArrayList {     public static void Main()       {         ArrayList myAL = new ArrayList();         myAL.Add( "the" );         myAL.Add( "quick" );         myAL.Add( "brown" );         myAL.Add( "fox" );         myAL.Add( "the" );            String myString = "the";         int myIndex = -1;         myIndex = myAL.IndexOf( myString, 4 );         Console.WriteLine(myIndex );     }     public static void PrintIndexAndValues(IEnumerable myList)     {         int i = 0;         foreach (Object obj in myList)             Console.WriteLine("   [{0}]:    {1}", i++, obj);     } }