Search Object in an ArrayList with offset in CSharp

Description

The following code shows how to search Object in an ArrayList with offset.

Example


using System;/*  www .j av  a  2s . c o  m*/
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" );
  

        foreach (Object obj in myAL){
            Console.WriteLine(obj);
        }

        String myString = "the";
        int myIndex = -1;

        myIndex = myAL.IndexOf( myString, 4 );
        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