Removing class collection object?
Hi. I've written my own class that inherits the CollectionBase class which i named it the ObjectCollection class. I implement this class as a type-safe collection that only permits the addition/removal of a custom class that i've written myself.
For eg.
Code:
Public Class Student
Name As String
Age As Integer
Address As String
DateOfBirth As Date
End Class
Public Class ObjectCollection
Inherits CollectionBase
Public Function Add(ByVal Obj As Student) As Integer
Return innerlist.Add(Obj)
End Function
Public Sub Remove(ByVal Obj As Student)
innerlist.Remove(Obj)
End Sub
Default Public Property Item(ByVal Index As Integer) As Student
Get
Return DirectCast(innerlist.Item(Index), Student)
End Get
Set(ByVal Value As Student)
innerlist.Item(Index) = Value
End Set
End Property
End Class
I would like to implement a Dispose method that removes all Student object from the ObjectCollection class. How do i do that?
Thanks,
Archaven