If you want to be able to do a foreach over a class (like you could by exposing NewEnum() as IUnknown in vb6) you can have your class implement IEnumerable - e.g.:
public class MyClass : IEnumerable
{
private List<string> items = new List<string>();
public MyClass()
{
items.Add("first");
items.Add("second");
}
public IEnumerator GetEnumerator()
{
return items.GetEnumerator();
}
}
which would allow you to use it like this:
MyClass myClass =new MyClass();
foreach (var itm in myClass)
{
Console.WriteLine(itm);
}
I've used List<string>
for simplicity, but you can use List<yourCustomClass>