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

Description

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

Example


using System;/*from  w  ww .j  a  v a2s  .  c o m*/
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, 8 );
      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