Search for the first occurrence of the duplicated value in a small section at the end 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( "jumps" );
myAL.Add( "over" );
myAL.Add( "the" );
myAL.Add( "lazy" );
myAL.Add( "dog" );
myAL.Add( "in" );
myAL.Add( "the" );
myAL.Add( "barn" );
String myString = "the";
int myIndex = -1;
myIndex = myAL.IndexOf( myString, 11 );
Console.WriteLine( myIndex );
}
public static void PrintIndexAndValues(IEnumerable myList)
{
int i = 0;
foreach (Object obj in myList)
Console.WriteLine(" [{0}]: {1}", i++, obj);
}
}
Related examples in the same category