using System;
using System.Collections;
public class EnumerableArrayList : IEnumerable
{
ArrayList al;
public EnumerableArrayList()
{
this.al = new ArrayList();
al.Add("Christoph");
al.Add("Christian");
}
public IEnumerator GetEnumerator()
{
return new MyEnumerator(this.al);
}
class MyEnumerator : IEnumerator
{
ArrayList al;
int index;
public MyEnumerator(ArrayList al)
{
this.al = al;
index = -1;
}
public object Current {
get
{
return al[index];
}
}
public bool MoveNext()
{
index++;
if (index >= al.Count) return false;
return true;
}
public void Reset()
{
index = -1;
}
}
}
class MainClass
{
public static void Main(string[] args)
{
EnumerableArrayList mal = new EnumerableArrayList();
foreach (object obj in mal)
Console.WriteLine(obj);
}
}