Search Object and returns index of the last occurrence within the sub range in the ArrayList in CSharp

Description

The following code shows how to search Object and returns index of the last occurrence within the sub range in the ArrayList.

Example


using System;//  w  w w.j a  v  a 2s  .com
using System.Collections;
public class SamplesArrayList  {
   public static void Main()  {
      ArrayList myAL = new ArrayList();
      myAL.Add( "A" );
      myAL.Add( "G" );
      myAL.Add( "C" );
      myAL.Add( "D" );
      myAL.Add( "G" );
      myAL.Add( "F" );
      myAL.Add( "G" );
      myAL.Add( "H" );
      myAL.Add( "I" );
      myAL.Add( "J" );
      myAL.Add( "K" );
      myAL.Add( "G" );

      String myString = "G";
      int myIndex = myAL.LastIndexOf( myString, 10, 6 );
      Console.WriteLine( myIndex );

   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary