Public Class ProductCollection : Inherits CollectionBase
Public Function Add(ByVal obj As Product) As Integer
Return Me.List.Add(obj)
End Function
Public Sub Remove(ByVal obj As Product)
If Me.List.Contains(obj) Then Me.List.Remove(obj)
End Sub
Default Public Property Item(ByVal index As Integer) As Product
Get
Return DirectCast(Me.List.Item(index), Product)
End Get
Set(ByVal Value As Product)
Me.List.Item(index) = Value
End Set
End Property
End Class
// Your structure. This should really be a class
// if you plan to use it with ArrayLists and not arrays.
public struct MyStruct
{
public int Total = 0;
}
// Instantiate an ArrayList.
ArrayList list = new ArrayList();
// Add structure to list.
list.Add(MyStruct);
// Loop through list and print out struct info.
foreach MyStruct s in list {
Console.Writeline(s.Total);
}